c++ Decision Making & Branching Statements


Decision Making & Branching Statements in C++ are

if else

else if (Ladder if)

if.. if.. if   Nested if  

 


if   else

in c++   if.. else control used for making a decision and chose branch means that if a condition is true control enter in if body otherwise else body(block/scope).

syntax

if(condition)

single statement;

else

single statement;

write a c++ program Given number is EVEN /ODD using  if else control decision making & branching statement

OUTPUT  OF  ODD-EVEN

Enter any value : 12

12 is EVEN

 


Nested if    ( if.. if.. if )

in c++   if.. if ..if  nested if   control   enter in if body  again  and again , than chose branch means  1 st if condition is true control enter another condition .. this type mechanism is called nested if..

syntax

if(condition-1)

{

if(condition-2)

{

if(condition-n)

{

statements of  condition – n ;

}

statements of  condition – 2 ;

}

statements of  condition – 1 ;

}

write a c++ program Given three values  and find maximum and  minimum is of them  using  nested if  control decision making & branching statement

OUTPUT  OF  Maximum-Minimum of three integer values


Ladder  if    ( else if )

in c++   else if  statement  known as Ladder if  statements in this control statement   if condition is false control   enter in next condition again false control enter next condition  till else block . .   if  any if block from first to last condition is  true control enter body and exit means skip all remain  other if condition.

syntax

if(condition-1)

statements – 1 ;

else if(condition-2)

statements – 2 ;

else if(condition-3)

statements – 3 ;

else if(condition-n)

statements – n ;

else

statements  ;

write a c++ program Given Five  values  and find maximum  of them  using  else if  ( Ladder if ) control decision making & branching statement

 

 

OUTPUT  of Five values for maximum

(Visited 100 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *


CAPTCHA Image
Reload Image