A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-151.c
1#include<stdio.h>
2intmain(void){
3intdigit='7'-'0';
4printf("%d\n",digit);
5return0;
6}
Conversions
Answer & explanation
Console output
7
Why
The character '7' has code 55 and '0' has code 48, so '7' - '0' is 7. Because the digit characters are contiguous in ASCII, subtracting '0' converts a digit character into its numeric value. This is the standard idiom for turning a character digit into an int.