Read two ints from input, add them, print the result.
This program reads two whole numbers, adds them, and prints the total. The new idea is scanf: it waits for you to type, then writes what you typed into a variable.
a + b with %d.user types 3 then 7
scanf waits until a number is available.first box fills
Need &a because scanf writes to the address.second box fills
Same idea for b.expression 10
No extra variable required.print 10
Format %d matches int.Each step highlights the matching C line. Program output appears only when a line that prints actually runs.
Five questions. Pick one answer each, then Check answers. The correct choice turns green.
1. Why does scanf need &a?
Pass the address so scanf can store.
2. Sample 3 and 7 prints:
3+7=10.
3. scanf("%d", &a) reads:
One integer.
4. If you write scanf("%d", a) without & for an int:
Need & for scalars.
5. a + b is evaluated:
The expression runs, then prints.