Nested If …Else Statements in C++

by Nideesh C on May 7, 2011 · 0 comments

in C++




If an if…else is specified within another if or else construct, then the structure is said to be nested if…..else construct.Nested if else statements

Syntax:

if (condition)

{

Statements;

.

.

if(condition)

{

statements;

.

.

}

else

{

statements;

.

.

}

.

.

}

else

{

Statements;

.

.

}

/*—————————————————————-*/

#include<iostream.h>

#include<conio.h>

void main()

{

char desig = ‘s’;

int sal=10000;

if(desig==’s')

if(sal>=5000)

cout<<”Eligible for bonud”;

else

cout<<”Not eligible for bonus”;

else

cout<<”Invalid Designation”;

getch();

}

/*—————————————————————————-*/

Output:

Eligible for bonus

See also: Swith….Case Statements in C++

 

Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. Nested if statements in C++
  2. if……else statements in C++
  3. C++ Program – Insertion of an object
  4. C++ Program – Binary File Handling
  5. Simple IF statement in C++

Leave a Comment

Previous post:

Next post: