0

An example of a program to determine the point equivalent to the grade using switch-case statement .....

A=12points,B=9points,C=6points,D=3points,E=0points

7th Mar 2017, 5:55 AM
chamaliakhan
2 odpowiedzi
+ 8
char grade; int points; // input grade switch (grade) { case 'A': points = 12; break; case 'B': points = 9; break; // and so on lol }
7th Mar 2017, 6:03 AM
Hatsy Rei
Hatsy Rei - avatar
+ 1
#include <iostream> using namespace std; int main (void){ int points; cout<<"Enter your points: "; cin>>points; if (points < 0 || points > 12){ cerr<<"Out of range (0-12)"; return -1; } switch (points){ case 10: case 11: case 12: cout<<"A"; break; case 7: case 8: case 9: cout<<"B"; break; case 4: case 5: case 6: cout<<"C"; break; case 1: case 2: case 3: cout<<"D"; break; default: cout<<"E"; } return 0; }
7th Mar 2017, 6:05 AM
देवेंद्र महाजन (Devender)
देवेंद्र महाजन (Devender) - avatar