Check Pass Or Fail using CPP

  1. Home
  2. Tutorials
  3. CPP
  4. CPP Programs
  5. If Else Statement
  6. Program

Source Code

#include <iostream>

using namespace std;

int main(int argc, char** argv) {
    
    // Variable Declaration for input
    int n;

    // Constant declaration of passing marks
     const int pass_marks = 33;

    // Taking marks input in variable n
    cout<<"Enter Obtained Marks: ";
    cin>>n;

    if (n >= pass_marks)
        cout<<"Pass\n";
    else
        cout<<"Fail\n";
    
    return 0;
}

Output

check pass or fail using if else statement in c++Working

In this program one variable is declared to get marks input. This variable is of int type, after declaration we take input in this variable using cin statement. Normally marks above than or equal to 33 considered as Pass and below 33 as Fail.

But this value can be set differently according to question/ requirement. Just we have to change value of const int pass_marks in source code. For this purpose we are using if else selection statement in this program. Last statement is used as return 0. Which means successful completion of program.

Comments
Login to TRACK of Comments.