if statement in c++
An if statement in C++ is used to make a decision in code. The syntax is as follows:
if (condition) {
// code to be executed if the condition is true
}
- The keyword "if" is used to start the if statement.
- The condition is placed in parentheses after the "if" keyword. This condition is evaluated to be either true or false.
- If the condition is true, the code inside the curly braces immediately following the if statement is executed.