CJCoding With Joseph
← Back to Question List
C Code Walkthrough #26

Casting a Double to an Int Truncates

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