Switch Case in C Language
The basic form of
a switch statement is:
switch (variable)
{
case expression1:
do something 1;
break;
case expression2:
do something 2;
break;
....
default:
do default processing;
}
Example of Switch
Case Program:
switch(
marks )
{
case 'A' : printf( "A++" );
break;
case 'B' : printf( "A+" );
break;
case 'C' : printf( "A" );
break;
case 'D' : printf( "B" );
break;
case 'F' : printf( "C" );
break;
default : printf( "YOU FAILED" );
break;
}
The keyword break must be included at the end
of each case statement. The default clause is
optional
© COPYRIGHT 2009 ALL RIGHTS RESERVED
FREECPROGRAMS.COM