switch Statement in c++




This video tutorial explains the switch statement in c++.
You will learn what is a switch statement, what is the use of switch statement, what is the syntax of switch statement, how to write the cases in switch, how to use break in switch, how to group cases in switch in detail with example.

source code for this tutorial

#include <iostream>

using namespace std;

int main()
{
char input = 'a';
switch( input ){
    case 'A' :
    case 'a' :    {
        cout << "excellent";
        break;

    }
        case 'B' : {
        cout << "Very good";
        break;
    }
        case 'C' : {
        cout << "good";
        break;
    }
        case 'D' : {
        cout << "not bad";
        break;
    }

    default : {
        cout << "dont know ur grade";
    }


}

cout << endl <<"done grading";

    return 0;
}

 
Back To Top