Answer to Question #302129 in C++ for Kidus

Question #302129

Write a C++ program that accepts marks of five students and then displays their average. The program should not accept mark which is less than 0 and mark greater than 100.


1
Expert's answer
2022-02-24T08:06:47-0500
using namespace std;
/*
	Write a C++ program that accepts marks of five students and then displays their average. 
	The program should not accept mark which is less than 0 and mark greater than 100.
*/


#define NO_OF_STUDENTS	5
#define MIN	0
#define MAX	100


int main()
{
	int n=0;
	float Marks,Avg=0;	
	
	while(n<NO_OF_STUDENTS)
	{
		Marks=MIN-1;
		while(Marks<MIN || Marks>MAX)
		{
			cout<<"Enter Marks ("<<MIN<<" to "<<MAX<<" of Student-"<<n+1<<": "; cin>>Marks;
		}
		Avg = Avg + Marks;
		n++;
	}
	Avg = Avg/NO_OF_STUDENTS;
	cout<<"\n\nFinal Average marks = "<<Avg;
	return(0);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog