Flash cards
Review the key moves
1/4
Core idea
What is the main idea behind C++ How To Add Two Numbers?
Lesson checks
Practice each idea before moving on
Short Mimo-style checks built from this lesson's code, terms, and sequence.
1Quick choice
Which statement best captures the main point of this lesson?
2Fill blank
Complete the missing token from the example code.
___ sum = x + y;Add Two Numbers
Learn how to add two numbers in C++:
Example
int x = 5;
int y = 6;
int sum = x + y;
cout << sum;Add Two Numbers with User Input
In this example, the user must input two numbers. Then we print the sum by calculating (adding) the two numbers:
Example
int x, y;
int sum;
cout << "Type a number: ";
cin >> x;
cout << "Type another number: ";
cin >> y;
sum = x + y;
cout << "Sum is: " << sum;