Sunday, 24 January 2016

Write A C++ Program For Finding A Grade Using Switch Case  

//Ghanendra Yadav
#include <iostream>
using namespace std;

int main ()
{
char grade = 'A';

   switch(grade)
   {
   case 'A' :
      cout << "Excellent!\n"; 
      break;
   case 'B' :
   case 'C' :
      cout << "Well done\n" ;
      break;
   case 'D' :
      cout << "You passed\n";
      break;
   case 'F' :
      cout << "Not Good try again\n";
      break;
   default :
      cout << "Invalid Choice\n";
   }
   cout << "Your grade is " << grade << endl;
   return 0;
}

Output:-




No comments:
Write comments

Recommended Posts × +