I tried to scan different data types by one after another. I got some issues with that and I didn't get the result I expected. I tried using fgets() and no improvement. Please explain how this works..Thank you

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() {
    int i = 4;
    double d = 4.0;
    char s[] = "Hello ";
    int ii;
    double dd;
    char ss[100];
    scanf("%d",&ii);
    scanf("%lf",&dd);
//Here I used fgets(),,I tried scanf also but no difference with the output
    fgets(ss,sizeof(ss),stdin);

    printf("%d\n",i+ii);
    printf("%0.1lf\n",d+dd);
    printf("%s",s);
    printf("%s",ss);
    return 0;
}

My input

12
4.0
How are you

Expected output

16
8.0
Hello How are you

My output

16
8.0
Hello 

0 Answers