A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-93.c
1#include<stdio.h>
2intmain(void){
3inta=7,b=2;
4doubler=(double)(a/b);
5printf("%.2f\n",r);
6return0;
7}
Conversions
Answer & explanation
Console output
3.00
Why
Here the cast wraps the whole result of a / b, which is computed in integers first as 7 / 2 = 3. Converting that 3 to double gives 3.00; the fraction was already lost. Compared to (double)a / b, this shows that where you place the cast determines whether the division is integer or floating point.