cplusplus exercise

I am trying to answer the exercises provided by the site,here is the link.

http://www.cplusplus.com/forum/articles/12974/

and im stuck at pancake glutton;

I am really confused on what I am going to do with the input person part.

since im new to programming,finding the largest number of the array is all i can do. I need help in doing the input person part.

this is is my code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include<stdio.h>
#include<iostream>

using namespace std;

int main(){



int a[10];
//Enter 10 persons
for (int x=0; x<10; x++)
cout<<"Person #:"<<endl;

// read the values;
{
for (int i=0; i<10; i++)

cin >> a[i];
}
// the loop
int max = a[0];
for (int i=1; i<10; i++)
if (a[i] > max) max = a[i];

// print the result
cout << "The largest number is " << max<<endl;





system("pause");
          
           }



the output should be like
// input
Person 3: //input number of cakes
//input
Person 9: // input number of cakes

up to 10 persons and then the program outputs the # of the Person and the # of cakes he ate...

I will appreciate any help..thanks..
Last edited on
"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)"

For this, you should have an array ready with 10 different indices, and then you should have a for loop that loops from 0 to 9. You would then output Person, followed by i+1, followed by a colon (:) and a space. Then you input to array index i.
1
2
3
4
struct person{
std::string name;
int pancakes; 
};

also remove the system pause please.
I can't really seem to pinpoint where to put the codes you said...
can you tell me what code I will add in what line??
Topic archived. No new replies allowed.