### While Loop Stops Output

So I was using an article on this site to give me ideas on what to program. I came up on the "Pancake Glutton" idea, and decided to give it a try. As I was testing it, the program suddenly stopped giving an output. Here is the code:

//
// Pancake Glutton
// Take 2
#include <iostream>
using namespace std;

int main() {
cout << "Ten people ate breakfast with you this morning. Each of them " <<
"had pancakes.\nPlease enter how many pancakes each of the ten people " <<
"ate.\n" << endl;

//Create an array called "customers" to hold the amounts of pancakes eaten
int customers[10][2] = {
{1, 0},
{2, 0},
{3, 0},
{4, 0},
{5, 0},
{6, 0},
{7, 0},
{8, 0},
{9, 0},
{10, 0}};

//Input the amounts of pancakes eaten
cout << "Person 1: "; cin >> customers[0][2]; cout << endl;
cout << "Person 2: "; cin >> customers[1][2]; cout << endl;
cout << "Person 3: "; cin >> customers[2][2]; cout << endl;
cout << "Person 4: "; cin >> customers[3][2]; cout << endl;
cout << "Person 5: "; cin >> customers[4][2]; cout << endl;
cout << "Person 6: "; cin >> customers[5][2]; cout << endl;
cout << "Person 7: "; cin >> customers[6][2]; cout << endl;
cout << "Person 8: "; cin >> customers[7][2]; cout << endl;
cout << "Person 9: "; cin >> customers[8][2]; cout << endl;
cout << "Person 10: "; cin >> customers[9][2]; cout << endl;

int i=0;
int pancakeNumber = 0;
int glutton;

while (i < 10)
{
if (customers[i][2] > pancakeNumber)
{ //If number of pancakes eaten
pancakeNumber = customers[i][2]; //is greater than the largest
glutton = i; //Make that index the "glutton"
i++; //And move on to the next person
}
}

cout << glutton << endl; //Display which person the glutton is
system("PAUSE");
return 0;
}

The while loop after int glutton does not work and seems to stop the program. I replaced the "glutton" in the cout with "testing testing" and it still did not work. However, when I commented out the loop, it appeared. Finally, it can't be what's inside the loop, because I commented that out too, and it still didn't work. Thanks in advance for your help!
Valid indices for an array of size 2 are 0 and 1. What does that say about the expression customers[i][2] ?
 ``12345678`` `````` for (int i = 0; i < 10; i++) { if (customers[i][2] > pancakeNumber) { //If number of pancakes eaten pancakeNumber = customers[i][2]; //is greater than the largest glutton = i; //Make that index the "glutton" } }``````
Topic archived. No new replies allowed.