Check Student Pass or Fail

Check Student Pass or Fail

Easy C++ Control Flow 38 views
Explanation Complexity

Problem Statement

A student needs 40 marks to pass. Check if student passed or failed.

Input Format

An integer marks.

Output Format

Print

• Pass
OR

• Fail

Example

45
Pass

Constraints

• Marks range: 0 to 100

Concept Explanation

A student passes only if marks are 40 or more.

Step-by-Step Explanation

1.Take input marks.

2.If marks ≥ 40:

• Print Pass.

3.Else:

• Print Fail.

Concept Explanation

A student passes only if marks are 40 or more.

Step-by-Step Explanation

1.Take input marks.

2.If marks ≥ 40:

• Print Pass.

3.Else:

• Print Fail.

Input / Output Format

Input Format
An integer marks.
Output Format
Print

• Pass
OR

• Fail
Constraints
• Marks range: 0 to 100

Examples

Input:
45
Output:
Pass

Example Solution (Public)

C++
oid control_q1_pass_fail() {
    int marks = 65;
    int passingMarks = 40;
    
    cout << "Student marks: " << marks << endl;
    
    if(marks >= passingMarks) {
        cout << "Result: PASS" << endl;
    } else {
        cout << "Result: FAIL" << endl;
    }
}

Official Solution Code

oid control_q1_pass_fail() {
    int marks = 65;
    int passingMarks = 40;
    
    cout << "Student marks: " << marks << endl;
    
    if(marks >= passingMarks) {
        cout << "Result: PASS" << endl;
    } else {
        cout << "Result: FAIL" << endl;
    }
}
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.