c++ switch selection control


switch in C++

It is used when user want to execute group of statement from available option it is used only with decimal integer constant or single character  constant.

Real(float,double) and string are not allowed.

It haves for keywords.( switch, case, break, default )

ANSI C permits the use of as many as 257 case labels.

 

Syntax

switch ( variable / constant / expression )

{

case value-1           :  block  1   ;   break ;

case value-2           :  block  2   ;   break ;

case value-N          :  block N   ;   break ;

default                    :  default block  ;

}

Next statement

To find the given alphabet is vowel or constant.

 

 

 

OUTPUT:

Enter  an alphabet : U

U is vowel

 

(Visited 50 times, 1 visits today)

Leave a Reply

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


CAPTCHA Image
Reload Image