Need Help !

Guys may i know what's the right code/logic here? I am new in programming. Please help.
------------------------------------------

Requires:
variables, data types, and numerical operators
basic input/output
logic (if statements, switch statements)
loops (for, while, do-while)
arrays

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
You just copy/pasted the exercise from the articles. If you need help with it post your code and ask a question please.
I see.. Anyway Can you give me some hints about that problem? Specially the last modify with 4 star. What will i use there? Should I use array ? Is it possible?
Yes you should use an array it inefficient to use a seperate variable for each person. Something like this:

1
2
3
4
5
int nNumberofPancakes[10];
for(int nIndex=0; nIndex<10; nIndex++)
{
  std::cout << "Person " << nIndex+1 << " ate " << nNumberofPancakes[nIndex];
}
Last edited on
then how about if i want to print and sort them in decreasing order?
Topic archived. No new replies allowed.