Solution for Exercise 5-9
ex0509
#include <stdio.h> int main() { printf("The total is %d\n",16.0+17); return(0); }
Output
The total is -90871768
Notes
* The compiler reads value 16.0 as a float because of the .0 part. The value 17 is still assumed to be an int.
* The results you may be different. I've seen -334073368 and 1606416648.
* The value isn't random. Instead, it's the printf() function trying to interpret what's become a floating point value as an int thanks to %d
.
Copyright © 1997-2024 by QPBC.
All rights reserved