Answer to Question #344546 in C++ for sami

Question #344546

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

1
Expert's answer
2022-05-24T13:54:53-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS