What's wrong with my code?

Hi,

i was trying to solve this exercise i found it here : http://www.cplusplus.com/forum/articles/12974/

here is the exercise:

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.


And this 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
#include <conio.h>

using namespace std;

int main() {

	int NumerOfPancakes[10];

	cout<<"\t Enter how many pancakes every person ate: \n";

	for (int i = 0; i < 10; i++)
	{
	  cout<<"Person "<<i+1<<": ";
	  cin>>NumerOfPancakes[i];

	}

	int max=0;
	int n;
	int min=2147483646;


	for (int i = 0; i < 10; i++)
	{
	 if (NumerOfPancakes[i] > max)
	 {
		 NumerOfPancakes[i]=max;
		 n=i;
	 }
	 }

	for (int i = 0; i < 10; i++)
	{
	 if (NumerOfPancakes[i] < min)
	 {
		 NumerOfPancakes[i] = min;
		 n=i;
	 }
	 }

	 cout<<"\n\n The One who ate the most pancakes for breakfast is the person number: "<<n+1;
	 cout<<"\n And  his number of pancakes is: "<<max<<endl;

	 cout<<"\n\n The One who ate the least pancakes for breakfast is the person number: "<<n+1;
	 cout<<"\n And  his number of pancakes is: "<<min<<endl;

	// Enter any key to continue code...
	cout << "\n\n\t\tPress any key to countinue..." << endl;
	getch();
	return 0;

}


So whatever the number i enter for the pancakes for every person it gives me the same output:


The One who ate the most pancakes for breakfast is the person number: 10
And  his number of pancakes is: 0


The One who ate the least pancakes for breakfast is the person number: 10
And  his number of pancakes is: 2147483646


So can anyone help me?

another Question out of the subject is how to make the links in my posts all blue and clickable?
The assignment operator works right to left, so you are assigning NumberOfPancakes[i] the value of min. The same happens for max.
The only place you ever assign min and max is on lines 21 and 19 respectively.

If you type something that looks like a valid URL, it should be clickable. The link you provided in your post is clickable for me.
Thanks Browni3141

it worked
thanks jsmith

now that i see it its clickable to me too.
Topic archived. No new replies allowed.