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

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);

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.