Flash cards
Review the key moves
1/4
Core idea
What is the main idea behind C++ Numbers and Strings?
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.
___ z = x + y; // z will be 30 (an integer)3Order
Put the learning moves in the order that makes the concept easiest to apply.
If you add two numbers, the result will be a number:
C++ uses the + operator for both addition and concatenation .
Adding Numbers and Strings
Adding Numbers and Strings
WARNING!
C++ uses the + operator for both addition and concatenation .
Numbers are added. Strings are concatenated.
If you add two numbers, the result will be a number:
int x = 10;
int y = 20;
int z = x + y; // z will be 30 (an integer)If you add two strings, the result will be a string concatenation:
string x = "10";
string y = "20";
string z = x + y; // z will be 1020 (a string)If you try to add a number to a string, an error occurs:
Example
string x = "10";
int y = 20;
string z = x + y;