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

Truncation vs Real Division in Casts

C code walkthrough · Question 40
mediumCasting

Code

Read carefully. What does this print?
1#include <stdio.h>
2int main() {
3 double d = 7.9;
4 int i = (int) d;
5 double avg = (double)(5 + 2) / 2;
6 printf("%d %.1f", i, avg);
7 return 0;
8}

Your answer