Question

help with C++

Write a program that prompts the user to enter the number of students and each student’s name and score, and finally displays the student with the highest score(display the student’s name and score). Also calculate the average score and indicate by how much the highest score differs from the average. Use a for loop.
0 0
Add a comment Improve this question Transcribed image text
✔ Recommended Answer
Answer #1
Dear,#include<iostream>

#include<string>

using namespace std;

void main()

{

int number_students;

string name[30];

int scores[30],highest,index=0;

double average;

//inputting students name

cout<<"Enter number of students:";

cin>>number_students;

int sum=0;

for(int i=0;i<number_students;i++)

{

cout<<"Enter student name"<<i+1<<":";

cin>>name[i];

cout<<"Enter score:";

cin>>scores[i];

sum+=scores[i];

}

highest=scores[0];

for(int i=1;i<number_students;i++)

{

if(highest<scores[i])

{highest=scores[i];

index=i;

}

}

average=static_cast<double>(sum/number_students);

cout<<"Student with highest score is:"<<name[i]<<endl;

cout<<"Average score:"<<average<<endl;

cout<<"Difference b/w highest and averege:"<<highest-average<<endl;

system("pause");

}//end main

answered by: Toshi
Add a comment
Know the answer?
Add Answer to:
help with C++
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT