Write a C++ program that display the percentage of persons that have passed the class
Posted by Samath
Last Updated: November 02, 2014

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;
}
Related Content
Simple Data Class using C++
Simple Data Class using C++
Samath | Jan 07, 2021
Account Class in C++
Account Class in C++
Samath | Jan 07, 2021
Car Class using C++
Car Class using C++
Samath | Jan 07, 2021
Circle Class in C++
Circle Class in C++
Samath | Jan 07, 2021
Invoice class using Java
Invoice class using Java
Samath | Jan 17, 2024
Movie Class in C++
Movie Class in C++
Samath | Jan 20, 2024
Rectangle Class in C++
Rectangle Class in C++
Samath | Jan 17, 2024
Movie Class in Java
Movie Class in Java
Samath | Jan 20, 2024
Student Class in Java
Student Class in Java
Samath | Jan 20, 2024
Glossary Class using Java
Glossary Class using Java
Samath | Jan 20, 2024
Vehicle Class using Java
Vehicle Class using Java
Samath | Jan 18, 2024
Phone Class using Java
Phone Class using Java
Samath | Jan 17, 2024
Airplane Class in Java
Airplane Class in Java
Samath | Jan 17, 2024