A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-40.c
1#include<stdio.h>
2intmain(void){
3doubleavg=(3+4)/2;
4printf("%.1f\n",avg);
5return0;
6}
Conversions
Answer & explanation
Console output
3.0
Why
Everything inside the expression is int: 3 + 4 is 7, and 7 / 2 is integer division giving 3. The conversion to double happens only when the result is assigned to avg, so the lost half can never come back, leaving 3.0. The double type of avg does not retroactively make the division floating point.