FreePrograms

  CONTACT US   ABOUT US   PRIVACY  DISCLAIMER

C Language Tutorial with Free C Programs

FREE C PROGRAMS 

What is C C vs C++ vs Java Program Structure Data Types in C Basic Rules of C & C++
Functions in C If, Else Conditions Loops in C Switch Case Arrays
Pointers Structures in C Strings in C Command Line Arguments Type Casting
Linked Lists Recursion Binary Trees Inheritance Multiple Inheritance
Templates File I/O Object Oriented Programming Data Structures in C C interview Questions

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