Please help me

Started by
1 comment, last by atomicajay 14 years, 2 months ago

/*******************************************************************************
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()
{
    const int MAX_ASK = 10;
    int person[MAX_ASK],cakes[MAX_ASK],leastcake;
    for (int i = 0; i < MAX_ASK; i++)
    {
        cout << "Enter cake eaten by person " << i << " : ";
        cin >> cakes;
        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
Advertisement
We're discouraged to help on homework questions, but don't you feel that "leastcake = cakes[0];" might be misplaced?
Problem solved!!!
Thanks for idea _fastcall
code was


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

{

if(cakes[j] < leastcake)

leastcake = cakes[j];





}

This topic is closed to new replies.

Advertisement