Let us see the C++ program to Calculate the percentage of marks and show grade using the switch statements. Percentage >= 90% : Grade A
Percentage >= 80% : Grade B
Percentage >= 70% : Grade C
Percentage >= 60% : Grade D
Percentage >= 40% : Grade E
Percentage < 40% : Grade F
Flowchart of the program to Calculate the percentage of marks and show the grade
Program in C++ to Calculate the percentage of marks and show the grade
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# include <iostream> # include <conio.h> using namespace std; int main() { int s1,s2,s3,s4,s5; float per; char grade; cout<<"enter marks of five subjects"<<endl; cin>>s1>>s2>>s3>>s4>>s5; per=((s1+s2+s3+s4+s5)*100)/500; cout<<per<<endl; switch (per>=90&&per<100) { case 1: cout<<"your grade is A"; break; case 0: switch(per>=80 &&per<90) { case 1: cout<<"grade is B"; break; case 0: switch(per>=70&&per<80) { case 1: cout<<"your grade is C"; break; case 0: switch (per>=60&&per<70) { case 1: cout<<"grade is D"; break; case 0: switch (per>=50&&per<60) { case 1: cout<<"grade is E"; break; case 0: cout<<"grade is F"; break; } break; } break; } break; } break; } } |
Output
SFT (Shamil’s Flow Table )
Are you interested to Read about SFT(Shamil’s Flow Table)?
C++ Program to input marks of subjects and show percentage, and grade without a switch statement
Click Here Read More about this Shamil’s Memory Table of grade program |
Latest posts by Prof. Fazal Rehman Shamil (see all)
- List of Public service commissions - August 31, 2020
- Comparison of fee structure of Pakistani Universities - June 1, 2020
- Past Guess Paper of Auditing - May 12, 2020