5 students going to submit their fee in a bank, they are in a line in front of the fee submission counter. After the submission of 3 students, 2 more students came and stand in that line. Your task to implement this scenario with a suitable algorithm.
#include <iostream>
using namespace std;
int main(){
int submitted = 0;
for(int i = 5;i > 0; i--){
cout<<"\nThere are currently "<<i<<" students at the queue.";
cout<<"\nOne student has submitted";
submitted++;
if(submitted == 3){
i += 2;
cout<<"\nTwo more students have joined the queue.\n";
submitted = 0;
}
}
cout<<"\nThe queue is empty!";
return 0;
}
Comments
Leave a comment