Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

pls help me find out this problem

0 votes
asked May 1, 2018 by Hawaii
write an if else statement that print excellent when score is 90 or higher good when score is between 80 and 89 try harder when score is less than 80 in c++

1 Answer

0 votes
answered May 2, 2018 by hudginsm (190 points)
#include <stdio.h>
#include <iostream>
using namespace std;

int main()
{
    int x;
    cout<<"please enter a score: ";
    cin>>x;
    if(x >= 90){
        cout<<"excellent!";
    }
    else if(x<90&&x>79){
        cout<<"good!";
    }
    else if(x<80){
        cout<<"try harder!";
    }
    return 0;
}

I think this is what you were looking for.
commented May 2, 2018 by hudginsm (190 points)
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

int main()
{
    //Declaration of variables
    int score;
    string eval;
    //Request for score
    cout << "please enter a score: ";
    cin >> score;
    //Evaluation of score
    if(score >= 90){
        eval = "excellent!";
    }
    else if((score < 90) && (score > 79)){
        eval = "good!";
    }
    else if(score < 80){
        eval = "try harder!";
    }
    //Output of information
    cout << "your score is: " << x << endl << y;
}

Here is a little more thought out way of doing it.
commented May 2, 2018 by anonymous
thank you sir for the help
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...