Answer to Question #200006 in C++ for Asad

Question #200006

Write a program to read marks of 10 students into an array and print index of all students whose marks are equal to average. 


1
Expert's answer
2021-05-28T06:16:25-0400


#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;
}

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