tags:

views:

91

answers:

2
#include<stdio.h>
void main()
{
int a=20,b=20;
float x=3.5, y=3.5;
printf("%d  %d   %f    %f  ",a,b,x,y);
printf("%d  %d   %f    %f  ",a,b,x,a);
printf("%d  %d   %f    %f  ",a,x,x,a);
printf("%d  %d   %f    %f  ",x,b,x,y);
}
A: 

I have no idea what you are asking, but you probably should change your float to double if you want to print them with "%f". Or you could cast the variables to double in the printf call.

nategoose
The `float` will get promoted to `double` when calling variadic functions.
Carl Norum
A: 

There is no way to predict the output of this program. It contains statements with undefined behaviour - mismatching printf() format specifiers with the types of the variables intended to fill them in cannot work. From the spec, Section 7.19.6.1, paragraph 9:

If a conversion specification is invalid, the behavior is undefined. If any argument is not the correct type for the corresponding conversion specification, the behavior is undefined.

Carl Norum