Hello,

I m doing an exercise i found in internet. The exercise is the following:

Pancake Glutton

Write a program that asks the user to enter the number of pancakes eaten for breakfast by 10 different people (Person 1, Person 2, ..., Person 10)
Once the data has been entered the program must analyze the data and output which person ate the most pancakes for breakfast.

★ Modify the program so that it also outputs which person ate the least number of pancakes for breakfast.

★★★★ Modify the program so that it outputs a list in order of number of pancakes eaten of all 10 people.
i.e.
Person 4: ate 10 pancakes
Person 3: ate 7 pancakes
Person 8: ate 4 pancakes
...
Person 5: ate 0 pancakes

I m doing the first part and am trying to output the biggest value entered in the program. Please dont do the exercise for me i just need some guidance. My program is outputing the last value enetered in the program not the biggest. What is the problem with that loop ?

This is my code:

``````#include <iostream>

using namespace std;

int main()
{
int person[10];
int tmp;

for (int n = 0; n < 10; n++)    //Loop for user input
{
cout<<"How many pancakes did you eat Person"<<(n+1)<<endl;
cin>>person[n];
}

for (int i = 0; i < 10; i++)    //Loop for comparing values and determinating the biggest value
{
for (int t = 0; t < 10; t++)
{
if (person[i] > person[t])
{
tmp = person[i];    //Should save the biggest value in tmp (But it doesnt)
}
}
}
cout<<"Biggest amount of pancakes eaten: "<<cout<<tmp<<endl; //outputs the biggest value

return 0;
}``````