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}};
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!
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"
}
}