← All problems
Add Two Numbers
Easy
7 solved
Add Two Numbers
Your first program. Read two whole numbers from the input and print their sum.
The two numbers arrive on one line, separated by a single space. Read both, add them, print the result on its own line.
💡
Read the numbers before you try to add them. Almost every beginner mistake here is a reading mistake, not a maths mistake.
Input
A single line with two space-separated integers a and b.
Output
A single integer: the sum of a and b.
Constraints
-10^9 <= a, b <= 10^9
Example 1
Input
3 4
Output
7
3 + 4 = 7
Submit runs your code against 5 test cases — the 1 shown above plus 4 hidden ones covering the awkward cases. Run sample just tries the first example, which is usually what you want while you are still working it out.