So I’m new to C++ and doing that one Buzzy’s exercise with pancakes. But I have absolutely no idea how to solve the last part of it:
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
That’s what I currently have.
#include <iostream>
using namespace std;
int main() {
int cc[10]; //the array for pancakes eaten.
int pn[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; //"number of the person" array.
cout << "how many pancakes they ate?nn";
for (int i = 0, n = 0; i < 10 && n < 10 ; i++, n++){
cout << "Person " << pn[n] << ": ";
cin >> cc[i];
}
cout << "n";
for (int i = 0, n = 0; i < 10 && n < 10 ; i++, n++){
cout << "person number " << pn[n] << " ate " << cc[i] << " pancakesn";
}
return 0;
}
But I honestly don’t know if I even think in the right direction. Very confused at this point.
gilewicz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.