#include <stdio.h>
#include <float.h>
#include <stdlib.h>
int main() {
float x = 3.8, y = 5.2;
int a, b, c;
float d = x + y;
a = d;
b = (int)(x + y);
c = (int)(3.8 + 5.2);
printf("a=%d,b=%d,c=%d\n", a, b, c);
return 0;
}
The result is
9,8,9
And I thought 9,9,9
is the right output, please tell me, why.