Review my Problem

Can anyone explain what could be better about this code please?
Is the use of if, else if, while statements being used correctly?


#include <iostream>
using namespace std;

int main()

int score;
char choice;

cout<<" *** Grading! ***"<<endl;
cout<<" Please enter score: ";
if (score==100){
cout<<" You scored a perfect score! good job. ("<<score<<")";
if (score>=90 && score<=99){
cout<<" You got an A! ("<<score<<"%)";
else if (score>=80 && score<=89){
cout<<" You got a B! ("<<score<<"%)";
else if (score>=70 && score<=79){
cout<<" You got a C! ("<<score<<"%)";
else if (score>100){
cout<<" Invalid input, try again";
else {
cout<<" Sorry, you failed. ("<<score<<"%)";
cout<<" Continue grading? (Y/N)";
}while (choice=='y' || choice=='Y');

return 0;


Last edited on
I think it's quite fine. Just add else before 2nd if, though this program would be working fine as well, but after adding else it'll become efficient. As no condition is checked after else's if one becomes true.
Topic archived. No new replies allowed.