#include <stdio.h>
int main(void)
{
int c;
float d = 5.6, e = 8.4;
c = d + e;
printf("c = d + e = %.2f \n", (float)c);
return 0;
}
Isn't float d=5.6
and float=8.4
automatically converted to int, so it becomes 5 and 8, respectively?
c=5+8=13
does not come out, and the value keeps coming out as 14...
In c=d+e;
, the =
operator has the lowest priority.
Therefore, d+e
is calculated first, and then the result is substituted for c
.
That is, 14.0 which is the sum of 5.6 and 8.4 is substituted for c.
© 2024 OneMinuteCode. All rights reserved.