1.3.2 Basic If/Else Statements
if (condition) {
// Statements if true
}
else {
// Statements if false
}If Statements
int score = 80;
if (score > 75) {
// Prints because score is greater than 75
cout << "Score is greater than 75" << endl;
} Else Statement
int score = 80;
if (score > 85) {
// Skips this block
cout << "Score is greater than 85" << endl;
}
else {
// Executes this block
cout << "Score is not greater than 85" << endl;
}Else If Statements
Summary
Clause
Use
Try This Example
Last updated