#include<stdio.h>
int main()
{
int i=4;
double d=4.0;
int ii;
double dd;
scanf("%d",&ii);
scanf("%lf",&dd);
printf("%d",i+ii);
printf("%lf",(d+dd));
return 0;
}
i am providing input 12 for integer and 4.0 for double. i am getting output as 168.00000 only but there is two print statement. I don't know why?
The result that you are seeing is completely expected. You are likely missing the fact that you have not included a newline in your printf statements.
Following your logic, you take 12 and add 4.0 to that. The result is 16, which you print. That brings us here:
16
You next print a floating point of dd+d
. Assuming 4.0, you now print out an 8.000. Putting those together (since there was no newline) you end up with:
168.000
This output should be considered like
16 8.00000
provided that you will insert a blank between the two numbers.
For example
printf("%d ",i+ii);
^^
printf("%lf",(d+dd));
Or you could insert the new ,line character
printf("%d\n",i+ii);
^^
printf("%lf\n",(d+dd));
^^
In this case you will get
16
8.00000
Take into account that according to the C Standard function main without parameters shall be declared like
int main( void )
^^^^^^
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.