int a=5; float b=3.5; printf(\"%d\",b); printf(\"\\n%f\",a);
Can anyone please tell me why this code is showing unexpected output (garbage\\n3.5)>
Because the a variable is a int type, while your are specifying a format string for a float type, and vice versa for the variable b.
a
b
Note :
%d is for integer type
%d
%f is for float type
%f
You should use :
int a=5; float b=3.5; printf("%f",b); printf("\n%d",a);