0

design an algorithm using IF statement to assign grades to an exam marks:
1.Marks below 40 is F
2.Marks greater than or equal to 40 and less than or equal to 50 is D
3.Marks greater than 51 and less than 70 is B
4.Marks greater than or equal to 71 is A

2
Contributors
1
Reply
3
Views
5 Years
Discussion Span
Last Post by phorce
0

than or equal to 40 and less than or equal to 50 is D
3.Marks greater than 51 and less than 70 is B

You should really attempt this by yourself. I don't know how the grades will be inputted (Whether it being through a .txt file etc) but this should help (Even if it is a little bit)..

#include <iostream>

using namespace std;

char algorithm(int theGrade)
{
    char theResult;

    if(theGrade < 40)
    {
        theResult = 'F';
    }else if(theGrade >= 40 && theGrade < 50){
        theResult = 'D';
    }else if(theGrade > 51 && theGrade < 70)
    {
        theResult = 'B';
    }else{
        theResult = 'A';
    }

    return theResult;
}

int main(int argc, char *argv[]) {

    int grade = 69;

    cout << algorithm(grade);

}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.