Pages

Sunday, October 20, 2013

Passed or Failed Grade code in c++

This will be the output:
if passed:


if failed:





This will be the code:
# include <iostream>
using namespace std;
int main ()
{
    int score;
    cout<<"Enter your score: "; cin>>score; cout<<endl;
    if (score >= 90)
    {
        cout<<"You got an A*"; cout<<endl;
        cout<<"You Passed"; cout<<endl;
    }
    else if (score >= 80)
    {
        cout<<"You got an A"; cout<<endl;
        cout<<"You Passed"; cout<<endl;
    }
    else if (score >= 70)
    {
        cout<<"You got a B*"; cout<<endl;
        cout<<"You Passed"; cout<<endl;
    }
    else if (score >= 60)
    {
        cout<<"You got a C"; cout<<endl;
        cout<<"You Passed"; cout<<endl;
    }
    else if (score >= 50)
    {
        cout<<"You got a D"; cout<<endl;
        cout<<"You Passed"; cout<<endl;
    }
    else if (score >= 40)
    {
        cout<<"You got a D"; cout<<endl;
        cout<<"You Failed"; cout<<endl;
    }
    else if (score >= 30)
    {
        cout<<"You got a E"; cout<<endl;
        cout<<"You Failed"; cout<<endl;
    }
    else if (score >= 20)
    {
        cout<<"You got a F"; cout<<endl;
        cout<<"You Failed"; cout<<endl;
    }
    else if (score >= 10)
    {
        cout<<"You got a G"; cout<<endl;
        cout<<"You Failed"; cout<<endl;
    }
    else if (score >= 1)
    {
        cout<<"You got a H"; cout<<endl;
        cout<<"You Failed"; cout<<endl;
    }
    cout<<endl;
    system ("pause");
}
.post {-webkit-user-select: none; -khtml-user-select: none; -moz-user-select: -moz-none; -ms-user-select: none; user-select: none;}

1 comment: