MeetCode - Programming Platform | MeetCode - Programming Solutions Platform

C++ Program to Check Student Pass or Fail with Explanation

C++ Easy Control Flow 39 views
This problem helps you practice core C++ fundamentals in a practical way. It builds intuition around pass, student, mark. Let’s break it down step by step so you can implement it confidently.
Back to Questions
Next Find Largest of Three Numbers Easy N

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

Constraints

• Marks range: 0 to 100

Concept Explanation

A student passes only if marks are 40 or more.

Step-by-Step Logic

1.Take input marks.

2.If marks ≥ 40:

• Print Pass.

3.Else:

• Print Fail.

Code Solution

This explanation is written for learning purposes and to help beginners understand the concept clearly.
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; } }

Output Example

Input:
45
Output:
Pass

Common Mistakes

- Misreading input/output format.
- Not handling constraints and edge cases.
- Off-by-one errors in loops.
- Forgetting to reset variables between test cases (if any).

Notes & Extra Practice

Solutions (0)

No solutions submitted yet. Be the first!

Next