I dont know why my min variable is keep showing zero (0). The min variable meant show what is the lowest pancake that was ate.
#include <iostream> using namespace std; int main() { int pancake[5]; int max=pancake[0]; int min=pancake[0]; int i; cout<<"Enter the number of pancake that the first person ate"<<endl; cin>>pancake[0]; if (pancake[i]<min){ min=pancake[i]; } if (pancake[i]>max){ max=pancake[i]; } for (i=1; i<5;i++){ cout << "Input the number of pancake that next person ate "<<endl; cin >> pancake[i]; // for ( int k=0;k<5;k++){// if (pancake[i]<min){ min=pancake[i]; } if (pancake[i]>max){ max=pancake[i]; } } for(int j=0; j<5;j++){ cout <<"Person "<<j<<": "<<pancake[j] << endl; } cout << "The greatest amount of pancake that was eaten was "<< max << endl; cout << "The least amount of pancake that was eaten was " <<min<<endl; }