Actually, I'm working on the ★★★★ modify, trying to sort by number of pancakes eaten. My loops to populate the two arrays work. My loop to display the data works. The issue is with the sort. After the data input, the program just stops. Here is my sort:
1. while (flag = 1) should have a double equals sign. With the code as is, it will do the while loop over and over.
2. The question says there are 10 people, yet you do numPancakes[counter + 1] when the counter is at 9. This is out of bounds of the array (assuming numPancakes was declared as int numPancakes[10];).
shacktar,
Thanks for your reply. Changing the while loop's condition to == worked, to a point.
Now, the whole program only works if I use numbers 1 through 10. It actually puts them in order, well if I enter them in reverse order. If I enter them in a random order, it will almost get them in the right order, but not quite. if I use numbers over 10, the output is still only numbers 1 to 10.
shacktar,
Also, when I change the loop conditional to 9, it only outputs 1 to 9. The tenth array position is not entered or output. Like this, it works.
It is the loop in the sort that needs to be < 9. So the loop on line 33.
The output is only ever going to print the numbers 1-10 (when you've corrected the error on line 33) regardless of what you enter, because you only print the gluttons array, not the pancakes array.