previous | start | next

The if/else Statement (Syntax 4.3 : if/else Statement)

Syntax 4.3 : if Statement

if (condition) statement1 else statement2
Example:
if (x >= 0) y = sqrt(x); else cout << "Bad input\n";
Purpose: Execute the first statement if the condition is true, the second statement if the condition is false.


previous | start | next