N customers enter the bakery to buy cookies. Each customer gets its turn[i], by
ID: 3803733 • Letter: N
Question
N customers enter the bakery to buy cookies. Each customer gets its turn[i], by computing a next number, and waits to be served. The clerk uses a counter to keep track of the served customers. The clerk serves the customer whose turn[i] is equal to the counter. After each serve (), the clerk increments the counter. When the counter reaches N, the clerk considers that it is done and leaves for home. (Shared variables) turn[i] = 0 i = 1, ..., N (N is initialized to 10) number = 0; served [i]=0; counter = 0; customer i() {number++; turn[i] = number; while (!served[i]){}; getServed(); go home;} clerk () {while (counterExplanation / Answer
#include <iostream.h>
#include <conio.h>
class workers
one : while(1)
cout<<" Choose your choice ";
cout<<"1) Create ";
cout<<"2) Display ";
cout<<"3) Jump to Main Menu ";
cout<<"Enter your choice:-";
cin>>choice;
switch(choice)
{
case {1|one">one : for(count=0,i=0;i<10;i++)
getch();
break;
case three : goto start;
default: cout<<" Enter selection is invalid try again ";
}
}
case two : while(1)
cout<<" Choose your choice ";
cout<<"1) Create ";
cout<<"2) Display ";
cout<<"3) Jump to Main Menu ";
cout<<"Enter your choice:-";
cin>>choice;
switch(choice)
{
case {1|one">one : for(count=0,i=0;i<10;i++)
getch();
break;
case three : goto start;
default: cout<<" Invalid choice try again ";
}
}
case three : while(1)
cout<<" Choose your choice ";
cout<<"1) Create ";
cout<<"2) Display ";
cout<<"3) Jump to Main Menu ";
cout<<"Enter your choice:-";
cin>>choice;
switch(choice)
{
case {1|one">one : for(count=0,i=0;i<10;i++)
getch();
break;
case three : goto start;
default: cout<<" Invalid choice try again ";
}
}
case four : goto end;
}
}
end:
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.