Answer to Question #196017 in C++ for IRUM

Question #196017

The counter desk of a school wants to keep the people in the queue not more than 5 at one

time. Make a system in c++ which adds students to the queue based on their roll numbers. As

soon as the count reaches 5, any new person isn’t allowed to stand in the queue.

The program should display that “No new student is allowed to stand in the queue”

However, as soon as a student from the queue of 5 people is done with his registration, the

program allows one more student to stand in the queue.


1
Expert's answer
2021-05-20T11:01:25-0400
#include<iostream>
#include<queue>
using namespace std;

int main(){

queue<int> registration;
cout<<"Student will go for the registration as per their roll number"<<endl;
registration.push(1);
registration.push(2);
registration.push(3);
registration.push(4);
registration.push(5);
registration.push(6);
while (!registration.empty()) {
        //if(registration.)
        if(registration.size()<6){
        cout << ' ' << registration.front();
        //registration.pop();
    }else{
        cout<<"wait!, student capacity increased"<<endl;

    }
registration.pop();
    }

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