else
suggest changeThe first sub-statement of an if statement may be followed by the keyword else
. The sub-statement after the else
keyword will be executed when the condition is false (that is, when the first sub-statement is not executed).
int x;
std::cin >> x;
if (x % 2 == 0) {
std::cout << "The number is even\n";
} else {
std::cout << "The number is odd\n";
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents