If and else statements in C++

Control Flow Statements in C++

If-then else

If the value of expression is nonzero, statement 1 is executed. If the optional else is present, statement 2 is executed if the value of expression is zero.expression must be of arithmetic or pointer type, or it must be of a class type that defines an unambiguous conversion to an arithmetic or pointer type.


 if (condition) {
 statements // execute if condition is true
 }//end of if

 if (condition)
 {
 statements // execute if condition is true
 } else
 if (condition)
 {
 statements // execute if condition is true
 } else
 if (condition)
 {
 statements // execute if condition is true
 }
 else
 {
 statements // execute if none of condition are true
 }

Program Output


---------Menu---------

1.choice1
2.choice2
3.choice3
----------------------
Please enter you choice: 2
menu2

You must be logged in to post a comment.

Proudly powered by WordPress   Premium Style Theme by www.gopiplus.com
%d bloggers like this: