Read the question, write C++ on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
Read two integers and print their sum.
std::cin >> skips whitespace, so the two numbers may be on one line or two — it reads them the same way.
Input. Two integers separated by space or newline.
Output. One integer: a + b
Constraints
- -1000000 ≤ a, b ≤ 1000000
Examples
Input
3 5
Output
8
Input
10 -4
Output
6
Hint
- int a, b; std::cin >> a >> b;
- Print a + b followed by "\n".
Show correct code
Peek only after you have tried. You can still Check your own version.
#include <iostream>
int main() {
int a, b;
std::cin >> a >> b;
std::cout << a + b << "\n";
return 0;
}
main.cppC++17 · g++ · Ctrl + Enter runs
ResultIdle
Run to see output. Check grades the tests.