not enough explaination

closed account (4y79216C)
3. write a program that allows the user to enter students name followed by their test score. it will first ask how many students to enter, then asks the students name followed by their score. it will then output the average of all scores, & the student w/ the highest & lowest test score. use one dimensional array for students name & another array for the score

save as prelim3-class score

expected output

how many student?2

enter student #1 name:tony

enter sruden tscore 50

enter student #1 name:t

enter sruden tscore 100

the highest score is t

the lowest score is tony

average is
closed account (4y79216C)
hello everyone can someone help me about array plsss i really need help right now plssss

using namespace std;
int main()

string name[50]={};
int s[]={};
int i;
int hn;
int l;
int k;
int n;
int largest;
int smallest;

float average;
cout<<"ENTER MANY many students?:"<<endl;
cout<<"ENTER name of students :"<<i<<":" ;
cout<<"ENTER SCORE:";




cout<<"THE HIGHEST IS"<<s[i];

To start with, here are a few points you should work on:
1. Reading the values, the for loop should start from 0 instead of 1.
2. Reading the values, if you read them into n and l, they will be overwritten with each for loop.
You should read the values into the arrays.

Try to print the values in the arrays after reading them, just to make sure you've taken the inut correctly.

3. Smallest and highest variables should be initialised. Assign the first element of the scores array to both the variables.
4. For loop to find highest and to find smallest should be independent of one another. One loop should not be inside another.
(you can use the same loop to find both as well. Just keep both if conditions inside the same for loop)

Any case, definitely go through this tutorial

Topic archived. No new replies allowed.