Categories
b. Variables and Keywords

switch, case and default

The switch and case statement is used when a block of statements has to be executed among many blocks. For example:

switch(expression)
{
    case '1':
    //some statements to execute when 1
    break;
    case '5':
    //some statements to execute when 5
    break;
    default:
    //some statements to execute when default;
}

Leave a Reply

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