Read the question, write C on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
Read two integers from stdin and print their sum.
Use scanf to read the numbers. Print only the sum, then a newline.
Input. Two integers a and b, separated by space or newline.
Output. One integer: a + b
Constraints
- -1000 ≤ a, b ≤ 1000
Examples
Input
3 5
Output
8
Input
10 -4
Output
6
Hint
- Declare two ints, then scanf("%d %d", &a, &b);
- Remember the & — scanf needs the address of each variable.
Show correct code
Peek only after you have tried. You can still Check your own version.
#include <stdio.h>
int main(void) {
int a, b;
if (scanf("%d %d", &a, &b) == 2) {
printf("%d\n", a + b);
}
return 0;
}
main.cC17 · gcc · Ctrl + Enter runs
ResultIdle
Run to see output. Check grades the tests.