a c++ program that reads the mark obtained of ten students out of 100.it also computer the average ; lowest and highest marks .then show the difference of marks of every student from average marks
Answers
Program:
#include<iostream>
using namespace std;
int main()
{
double Marks[10];
cout<<"Enter marks of 10 students (out of 100):\n";
for(int i = 0 ; i < 10 ; i++)
{
cin>>Marks[i];
}
double sum = 0, avg, highest = Marks[0], lowest = Marks[0];
for(int i = 0 ; i < 10 ; i++)
{
sum = sum + Marks[i];
if(Marks[i] > highest)
{
highest = Marks[i];
}
if(Marks[i] < lowest)
{
lowest = Marks[i];
}
}
avg = sum / 10.0;
cout<<"\nAverage Marks = "<<avg<<endl<<endl;
cout<<"Lowest Marks = "<<lowest<<endl<<endl;
cout<<"Highest Marks = "<<highest<<endl<<endl;
cout<<"Difference of marks of every student from average marks :"<<endl;
for(int i = 0 ; i < 10 ; i++)
{
cout<<(Marks[i] - avg)<<endl;
}
return 0;
}
Output:
Enter marks of 10 students (out of 100):
10
20
30
40
50
60
70
80
90
100
Average Marks = 55
Lowest Marks = 10
Highest Marks = 100
Difference of marks of every student from average marks :
-45
-35
-25
-15
-5
5
15
25
35
45