The switch case statement allows you to select from multiple choice based on a set of fixed value for a give expression.The value of the variable given into switch is compared to the value following each of the cases.And when one value matches the value of the variable,the computer continues executing the program from that point.
Syntax of the 'switch case' statement is:
switch(expression)
{
case value1: /*execute code1*/
break;
case value2: /*execute code2*/
break;
.....
default: /*execute default action*/
break;
}
Example:
/*Program ...
Friday, July 1, 2011
Subscribe to:
Posts (Atom)