#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);
}
views:
91answers:
2
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
2010-09-24 16:28:56
The `float` will get promoted to `double` when calling variadic functions.
Carl Norum
2010-09-24 16:29:24
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
2010-09-24 16:28:59