Write a program to read marks of 10 students into an array and print index of all students whose marks are equal to average.
#include <iostream>
using namespace std;
int main()
{
int n=10;
int marks[n];
int sum=0;
int avg;
for(int i=0;i<n;i++){
cout<<"\nEnter marks of student "<<i+1<<": ";
cin>>marks[i];
sum=sum+marks[i];
}
avg=sum/n;
cout<<"\nIndex of students whose marks are equal to average are: \n";
for(int i=0;i<n;i++){
if (marks[i]==avg){
cout<<i<<endl;
}
}
return 0;
}
Comments
Leave a comment