If Else Statement in C++

Download
Download is available until [expire_date]
  • Version
  • Download 15
  • File Size 1.31 KB
  • File Count 1
  • Create Date April 27, 2016
  • Last Updated April 27, 2016

If Else Statement in C++

If Else Statement in C++

Sample program that demonstrate if else statement in c++. The program will ask to enter a grade, if your grade is greater than or equal to 75 then you have a passing grade, grade less than 75 means failure.

Source code:

#include < iostream >

using namespace std;

int main()
{
    double mygrade;
    cout << "Enter your grade: " << endl;
    cin >> mygrade;

    if (mygrade >= 75 || mygrade <= 100)
    {
        cout << "You passed!, Congratulations" << endl;
    }
    else
    {
        cout << "Sorry you failed!, study hard next time" << endl;
    }

    return 0;
}
, , , , , ,

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.