if

suggest change

The keyword if must be followed by a parenthesized condition, which can be either an expression or a declaration.

If the condition is truthy, the sub-statement after the condition will be executed.

#include <iostream>

int main()
{
    int x = 1;
    if (x > 0) {
        std::cout << "x (" << x << ") is greater than zero\n";
    }
}
x (1) is greater than zero

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents