You are here

if then else Syntax within C++

6 February, 2015 - 15:43

The syntax for the if then else control structure within the C++ programming language is:

Example 12.1: C++ source code: Layout of an if then else

if (expression)   {   statement;   } else   {   statement;   } 

 

Note: The test expression is within the parentheses, but this is not a function call. The parentheses are part of the control structure. Additionally, there is no semicolon after the parenthesis following the expression.