When I run this code the output of D comes out as the value of C. Is it because I call for a float and it just takes the most recent float in the memory?
#include <stdio.h>
int main()
{
int a=3/2;
printf("The value of 3/2 is : %d\n", a );
float b=3.0/2;
printf("The value of 3/2 is : %f\n", b );
float c=7.0/2; <-------
printf("The value of 3/2 is : %f\n", c );
int d=3.0/2;
printf("The value of 3/2 is : %f\n", d ); <-------
return 0;
}
The value of 3/2 is : 1
The value of 3/2 is : 1.500000
The value of 3/2 is : 3.500000
The value of 3/2 is : 3.500000
Arguments that do not match the type indicated by the format specifier yield undefined behaviour (cf., for example, cppreference/printf):
And undefined behaviour is undefined; it might crash, it might print out nothing, anything, or even something looking correct. Confer, for example, the definition of undefined behaviour in this online c draft standard: