Hello I have an issue, I am writing a program where I am trying to find out who ate the most pancakes. And I don't know what I am doing wrong, can you tell me what I can do to fix my code. I only wrote down two if/else statements because I wanted to make sure I was doing it correctly before doing the same thing to every problem.
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.
★★★★ Modify the program so that it outputs a list in order of number of pancakes eaten of all 10 people.
i.e.
Person 4: ate 10 pancakes
Person 3: ate 7 pancakes
Person 8: ate 4 pancakes
...
Person 5: ate 0 pancakes
*/#include <iostream>
usingnamespace std;
int main()
{
//variables
int person1=0;
int person2=0;
int person3=0;
int person4=0;
int person5=0;
int person6=0;
int person7=0;
int person8=0;
int person9=0;
int person10=0;
//output message
cout<<"Enter the number of pancakes eaten by 10 different people."<<endl;
//create a list of the people
cin>>person1;
cin>>person2;
cin>>person3;
cin>>person4;
cin>>person5;
cin>>person6;
cin>>person7;
cin>>person8;
cin>>person9;
cin>>person10;
//make program analyze the data and output who ate the most pancakes
if(person1>person2&&person3&&person4&&person5&&person6&&person7&&person8&&person9&&person10)
{
cout<<"Person 1 ate the most pancakes."<<endl;
}
elseif (person2>person1&&person3&&person4&&person5&&person6&&person7&&person8&&person9&&person10);
{
cout<<"Person 2 ate the most pancakes."<<endl;
}
return 0;
}
You don't have to loop back person1, into your second else if, it should decrease since you already know for sure person 1 isn't greater than either 2,3,...10.