By 25/02/2014 13 Comments

if-else Statement in C++

The if-else statement is another decision making statement. The if-else statement contains the keywords if and else which are predefined in C++. The condition is contained in the parentheses () after the keyword if. If the condition is satisfied then the block of code after the keyword if is executed while if the condition is not satisfied then the control is transferred to the else and the block of code contained after it is executed. If you want to execute the single statement if the condition is either satisfied or not then you don’t have to enclose it in the curly braces but if you want to execute certain block of code (multiple statements) then you have to enclose the block of code in the curly braces. The syntax of the if-else statement is given below;

 

if (a>b && a>c)
statement;         Single Statement if body
else
statement;         Single Statement else body

if (a>b && a>c)
{
statement;
statement;            Multiple Statement if body
statement;
}
else
{
statement;
statement;            Multiple Statement else body
statement;
}

Flow chart of if-else Statement

if-else-flowchart







Posted in: C++ Basics

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .