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>
#include <conio.h>
usingnamespace 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?