Ok! I'm almost done with this simple program lol
variables, data types, and numerical operators
logic (if statements, switch statements)
loops (for, while, do-while)
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.
★★★★ Modify the program so that it outputs a list in order of number of pancakes eaten of all 10 people.
Person 4: ate 10 pancakes
Person 3: ate 7 pancakes
Person 8: ate 4 pancakes
Person 5: ate 0 pancakes
The if statement to find the highest value works, However the if statement to find the lowest value does not work correctly!! It always gives me the last number that I imput into the array as the lowest value, which sometimes it is not.
Please, can one look over the code and make sure to read the comments!? thankyou (:
// Pancake Glutton.cpp : Defines the entry point for the console application.
using namespace std;
int _tmain(int argc, _TCHAR* argv)
//The array called "Pancakes" has 10 elements for the 10 people
int temp = 0; //Temp is the lowest possible value in the array
int Lowest_Value = 0; //Variable for the lowest value haha
cout << "Please enter in the number of pancakes eaten for breakfast by 10 different people\n";
//Loop that finds the person who ate the most pancakes
for(int i = 0; i <= 9; i++)
cin >> Pancakes[i];
//I made the lowest_value equal to the minimum element in the array (aka the first number imputed)
Lowest_Value = Pancakes;
//if statement to find the highest value
//If the value entered is greater than temp, the value of temp changes to that and so on...
if (Pancakes[i] > temp)
temp = Pancakes[i];
//If statement to find the minimum value
//If the number imputed is lower than the first number imputed, it changed to that value
if (Pancakes[i] < Lowest_Value)
Lowest_Value = Pancakes[i];
cout << "The highest number of pancakes eaten is " << temp << endl
<< "The lowest number of pancakes easten is " << Lowest_Value << endl;