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
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents