1. To start off you'll want to make your array
int Person [10];
2. Now you'll want to input how much each person ate. You can do this with a for loop since it's considered a counted loop
for (int i = 0 ; i <= 9 ; i++)
cin >> Person [i];
3. Now you'll want to keep track of the max value and the min value.
There's many ways to go about this. But I'll show you one method.
make a boolean variable named "setminmax"
bool setminmax = false;
Now you remember the for loop in step 2? We're going to add to that. but first we need to make 2 more integer variables
int max , min;
Now for our for loop
for (int i = 0 ; i <= 9; i ++) {
cin >> Person [i];
if (!setminmax){
Person [i] = Min;
Person [i] = Max;
setminmax = true;}
if (Person [i] > Max)
Person[i] = Max;
else if (Person [i] < Min )
Person [i] = Min;
} // End of If Statement
}
Now that's a lot of code but I'll explain it
First I got the value of the first person.
Then I made my if statement
if (!setminmax){
Person [i] = Min;
Person [i] = Max;
setminmax = true;}
This basically sets the value of person one to the Min and Max Value.
We do this because when you enter the value for person 2 then the Max or Min value will change.
if (Person [i] > Max)
Person[i] = Max;
else if (Person [i] < Min )
Person [i] = Min;
You see this statement after. this will basically change the value of Max and Min depending on what you enter for the next Person
For Example say the value for Person [0] = 5;
if the value of Person [1] = 10 then the value of Person[1] will be equal to Max
4. Now to Display the max value you could simply put
cout << Max;
But the problem is that more than one person might have the same Max value so we have to create another for loop to display the max value.
for (int i = 0 ; i <= 9 ; i ++) {
if (Person [i] == Max)
cout << Person [i] << " ate " << Max << " Pancakes" << endl;
}
5. You'll do the same for Min
for (int i = 0 ; i <= 9 ; i ++) {
if (Person [i] == Min)
cout << Person [i] << " ate " << Min << " Pancakes" << endl;
}
6. To display them in order from highest to lowest I'll let you figure that part out because I don't want to do all your hw for you.
So I Hope This Helped :D
If you have any further questions don't be afraid to ask