- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

In this problem, we are given an array stu[] of size n denoting the marks of students in the class. For each student, the maximum mark is 100 and a student needs 50 marks to pass the exam. Our task is to create a program to find the Maximum students to pass after giving a bonus to everybody and not exceeding 100 marks.

**Problem Description** − We need to give bonus marks to students to pass but the bonus marks will be given to all students. Our task is to maximize the number of students that can pass the exam by giving the bonus marks but no student should get marks more than 100 after giving a bonus. And then return the maximum number of students passing.

**Let’s take an example to understand the problem,**

stu[] = {45, 32, 78, 10, 53, 67}

5

All students passed are : 45 + 22 = 67 32 + 22 = 54 78 + 22 = 100 53 + 22 = 75 67 + 22 = 89

To solve the problem, we need to give marks to the student but one thing to consider is the maximum marks of any student should not exceed 100. So the maximum bonus that can be given is

Student with max marks(M) + bonus = 100 Bonus = 100 − M

Then we will add this bonus to students' current marks. If it exceeds 50, students pass. The result will be the count of all such students.

**Initialise**

passCount = 0;

**Step 1** −

Find the student with maximum marks, maxMarks.

**Step 2** −

Calculate bonus that can be given to all students, bonus = 100 − maxMarks.

**Step 3** −

Loop for i −> 0 to n−1

**Step 3.1** −

if(stu[i] + bonus >= 50), passCount++.

**Step 4** −

return passCount.

**Program to illustrate the working of our solution,**

#include<iostream> using namespace std; int calcPassCount(int stu[], int n) { int maxMarks = stu[0]; for(int i = 1; i < n; i++){ if(stu[i] > maxMarks) maxMarks = stu[i]; } int bonusMarks = 100 − maxMarks; int passCount = 0; for(int i=0; i<n; i++) { if(stu[i] + bonusMarks >= 50) passCount ++; } return passCount; } int main() { int stu[] = {45, 32, 78, 10, 53, 67}; int n = sizeof(stu)/sizeof(stu[0]); cout<<"The Maximum students to pass after giving bonus to everybody is "<<calcPassCount(stu, n); return 0; }

The Maximum students to pass after giving bonus to everybody is 5

- Related Questions & Answers
- Maximum students to pass after giving bonus to everybody and not exceeding 100 marks in C++
- C program to find marks of students for boys or girls
- Finding average marks of students for different subjects and display only the highest average marks in MySQL
- Program to find maximum average pass ratio in Python
- Program to find maximum element after decreasing and rearranging in Python
- Maximum number of chocolates to be distributed equally among k students in C
- MySQL new user access denied even after giving privileges?
- Truncating multiple strings after 100 characters in ABAP
- C# Program to pass Parameter to a Thread
- Program to find maximum adjacent absolute value sum after single reversal in C++
- Program to find maximum binary string after change in python
- How to pass objects to functions in C++ Program?
- Print 1 to 100 in C++, without loop and recursion
- How to write on selection screen after giving any user input in SAP ABAP
- Maximum profit after buying and selling the stocks in C++

Advertisements