Sunday, June 8, 2014

C++ Beginners Tutorial 7 - Switch Statement



#include <iostream>
using namespace std;
int main()
{
    char grade;
    cout<<"Please Enter the grade"<<endl;
    cin>>grade;

    switch(grade)
    {
       case 'a':
       case 'A' : cout<<"Excellent"<<endl;
       break;
        case 'B' : cout<<"Very Good"<<endl;
       break;
        case 'C' : cout<<"You Passed"<<endl;
       break;
        default:
            cout<<"Invalid Entry"<<endl;
       break;

    }
    return 0;
}

No comments:

Post a Comment