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.
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);
}
Comments
Leave a comment