Maximum students to pass after giving bonus to everybody and not exceeding 100 marks | C ++ Implementation of above approach . ; Function to return the number of students that can pass ; maximum marks ; maximum bonus marks that can be given ; counting the number of students that can pass ; Driver code
#include <iostream> NEW_LINE #include <algorithm> NEW_LINE using namespace std ; int check ( int n , int marks [ ] ) { int * x = std :: max_element ( marks , marks + 5 ) ; int bonus = 100 - ( int ) ( * x ) ; int c = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( marks [ i ] + bonus >= 50 ) c += 1 ; } return c ; } int main ( ) { int n = 5 ; int marks [ ] = { 0 , 21 , 83 , 45 , 64 } ; cout << check ( n , marks ) << endl ; return 0 ; }