Adsense 728 * 15

Search

Custom Search

Program to Count Number of Students having Passing Marks

Write a C, C++ program that will accepts marks of  students and then print total number of students having passing marks.

In this questions, we have to take following things as an input -

i)   No. of students
ii)  Marks of all the students
iii) Passing marks

C++ Program to Count Number of Students having Passing Marks


#include <iostream.h> 
using namespace std;

int main() {
 
   float arr[100], pgrade;
   int n, i, count = 0;
 
   //Enter number of students
   cout << "Enter the number of students (Max 100)\n";
   cin  >> n;
 
   cout << "Enter their marks \n";
 
   //Input their marks
   for(i = 0; i < n; i++) {
         cin >> arr[i];
   }
 
   //Input passing grade
   cout << "Enter the passing marks \n";
   cin  >> pgrade;
 
 
   //Count number of students passed
   for(i = 0; i < n; i++) {
        if(arr[i] >= pgrade) {
           count++;
        }
   }
 
   cout << "Total number of students having passing
           grade is " << count;
   return 0;
}



Output : -

Enter the number of students (Max 100) : 10

Enter their marks :
34
25
67
89
12
89
90
78
15
2

Enter their passing marks :
50

Total number of students having passing marks is : 5


No comments:

Post a Comment