if statement
From cppreference.com
Conditionally executes code.
Used where code needs to be executed only if some condition is present.
Contents |
[edit] Syntax
if ( expression ) statement_true
|
|||||||||
if ( expression ) statement_true else statement_false
|
|||||||||
[edit] Explanation
expression shall be an expression, convertible to bool.
If it evaluates to true, control is passed to statement_true, statement_false (if present) is not executed.
Otherwise, control is passed to statement_false, statement_true is not executed.
[edit] Keywords
[edit] Example
Run this code
Output:
first is false i == 3 i != 3 is false