Jump to content
  • Advertisement
Sign in to follow this  
atomicajay

Please help me

This topic is 3028 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

/*******************************************************************************
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

Share this post


Link to post
Share on other sites
Advertisement
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];





}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!