The minimal pass mark of a class is 70%. Develop a C++ console application that enables a user to initially enter the number of persons in the class and consequently enter the numerical grades of each student. Furthermore the program should display the percentage of persons that have passed the class.
Here is the Solution to the problem above:
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int num_of_persons;
float grade;
int pass = 0;
float percentage;
cout<<"Enter the number of persons in the class: ";
cin>>num_of_persons;
for(int i=0;i<num_of_persons;i++)
{
cout<<"Enter grade: ";
cin>>grade;
if(grade >= 70)
{
pass++;
}
}
percentage=(100/num_of_persons)*pass;
cout<<percentage<<"% of the students pass the class"<<endl;
return 0;
}