Determine if a Grade is Passing or Failing (If-Else Logic)

Determine if a Grade is Passing or Failing (If-Else Logic) in C++

Master conditional statements and input handling by creating a program that evaluates academic performance based on a specific threshold.

Decision Making Logic

Relational Operators

Using the >= operator allows the program to compare the user's input against the threshold of 60 to return a boolean result.

If-Else Branching

This structure directs the program flow into two distinct paths: one for success (True) and another for failure (False).

Step-by-Step Objective

  • Prompt the user to enter a numeric grade (0–100).
  • Store the input value in an int variable.
  • Evaluate if the value is 60 or higher using an if statement.
  • Display "Passing" for successful results and "Failing" otherwise.

C++ Solution

grade_checker.cpp Flow Control
#include <iostream>
using namespace std;

int main() {
    int grade;

    cout << "Enter your grade (0-100): ";
    cin >> grade;

    // Check the condition
    if (grade >= 60) {
        cout << "Passing" << endl;
    } else {
        cout << "Failing" << endl;
    }

    return 0;
}

Console Output:

Enter your grade (0-100): 75
Passing
Flow Control & Relational Logic
Conditional Logic Relational Operators Input Handling Program Flow Educational Algorithms

Share this C++ Exercise

Help others learn algorithms and flow control in C++.

© C++ Programming Exercises. Master the art of performance coding.