Write a program that accepts student mark out of 100, and return the corresponding letter grade based on the following condition:
if mark is greater than or equal to 90 A
if mark is greater than or equal to 80 and less than 90B
if mark is greater than or equal to 60 and less than 80C
if mark is greater than or equal to 40 and less than 60D
if mark is less than 40F
for other cases NG
N.B write the program using both switch and if-else if- else Statements.
It is known that a score for a given course is b/n 0-100
#include <iostream>
using namespace std;
int main() {
int mark;
cout<<"Student mark between 0 and 100: ";
cin>>mark;
if(mark>=0 && mark<40)
cout<<"F";
else if(mark>=40 && mark<60)
cout<<"D";
else if(mark>=60 && mark<80)
cout<<"C";
else if(mark>=80 && mark<90)
cout<<"B";
else if(mark>=90 && mark<=100)
cout<<"A";
else
cout<<"NG ";
cout<<endl;
return 0;
}
Comments
Leave a comment