CJCoding With Joseph
15free / daySign inCreate account
Back to Code Walkthrough

Casting a Double to an Int Truncates

C code walkthrough · Question 26
mediumCasting

Code

Read carefully. What does this print?
1#include <stdio.h>
2int main() {
3 double d = 3.99;
4 int x = (int)d;
5 printf("%d %.2f\n", x, d);
6 return 0;
7}

Your answer