## Recommended Posts

atomicajay    100
/*******************************************************************************
Pancake Glutton
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.

*****************************************************************************/
#include <iostream>
using namespace std;

int main()
{
for (int i = 0; i < MAX_ASK; i++)
{
cout << "Enter cake eaten by person " << i << " : ";
cin >> cakes[i];
cout << endl;
}

for (int j = 0; j < MAX_ASK; j++)
{
leastcake = cakes[0];
if(cakes[j] > leastcake)
leastcake = cakes[j];

}
cout << "Least cake eaten is: " << leastcake << endl;
system("pause");
return 0;

}

Not getting proper result

##### Share on other sites
fastcall22    10845
We're discouraged to help on homework questions, but don't you feel that "leastcake = cakes[0];" might be misplaced?

##### Share on other sites
atomicajay    100
Problem solved!!!
Thanks for idea _fastcall
code was

[code]
leastcake = cakes[0];
for (int j = 0; j < MAX_ASK; j++)

{

if(cakes[j] < leastcake)

leastcake = cakes[j];

}