C programming · Lesson
Read two integers, compute the sum and print the result.
scanf reads values, assignment processes state and printf makes the result observable.
INPUT a → INPUT b → sum = a + b → OUTPUT sum
Use Start and Step: when the active block changes, ConceptStep also highlights the C lines representing that same step.
Run C executes only the example shown on the left, using stdin on the right. The coding challenge below has a separate editor and test button.
1#include <stdio.h>
2
3int main(void)
4{
5 int a;
6 int b;
7 int somma;
8
9 scanf("%d", &a);
10 scanf("%d", &b);
11 somma = a + b;
12 printf("%d\n", somma);
13 return 0;
14}
Read two integers and print their sum.
This is a different program from lab 1. Complete the starter code: Check all test cases compiles this editor and tests every input, including boundary cases.
With inputs 5 and 3, which value is printed?
Challenge 1 / 5 · Understanding
Progress: 0 / 5 · correct: 0
ConceptStep separates what is required from what is recommended or useful as reinforcement. Only required prerequisites block your progress.
Relationships: solid line = required · dashed line = recommended · dotted line = reinforcement.