You must do this to a variable before it can be used.
What is declare it?
C++ uses these for more readable conditional values compared to using 1 and 0.
What are true and false?
This selection statement allows you to use compound expressions and relational operators.
What is an if statement?
Use this when you know how many times you want to execute a loop.
What is a for loop?
People WILL enter bad data, so you should do this.
What is validate user input?
You should do this to a variable before you use its value.
What is initialize it (i.e., set it to a value)?
Use these delimiters around a condition.
What are parentheses?
This selection statement allows you to choose between multiple characters or integers.
What is a switch statement?
This general loop statement takes only a condition and will not execute if its condition is initially false.
What is a while loop?
This loop is best for data validation because it always executes at least once.
What is a do while loop?
Use this statement, so you don’t have to write std::cin, std::cout, and std::endl.
What is using namespace std;?
After ! (i.e., not), this logical operator has the highest precedence.
What is && (i.e., and)?
The selection statement below has this logical error.
if (x > 7);
{
cout << “false”;
}What is the ; after the condition?
With which loop can you easily replace a for loop?
What is a while loop?
This lets you detect that the user entered a string when cin is attempting to retrieve an integer.
What is cin.fail()?
This is how you can retrieve input from the console and store it in num.
What is cin >> num;?
For this logical operator, the expression on its right will NOT be executed, if the one on its left is true.
What is || (i.e., or)?
These delimiters should go around multiple lines of code you want to execute when the condition for an if statement is true.
What are curly braces { }?
Although you could, you should NOT use this to terminate a loop.
What is break?
This occurs when cin.ignore() is called with no parameters.
What is a single character dropped from the stdin buffer?
This shorthand allows you to add 1 to num.
What is num++ OR ++num OR num+=1?
For this logical operator, the expression on its right will NOT be executed, if the one on its left is false.
What is && (i.e., and)?
For a switch statement, this is like an if statement’s else.
What is default?
Although you could, you should NOT use this to skip a loop iteration.
What is continue?
Use this after you’ve tested for bad data entry and dealt with it.
What is cin.clear()?