当我运行此代码时,D的输出作为C的值出现。是因为我要求一个浮点数,它只需要内存中最近的浮点数吗?
#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