Answer to Question #182502 in C++ for Muhammad ali

Question #182502

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.


1
Expert's answer
2021-04-17T07:54:26-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS