Computers and Technology, 20.11.2019 22:31 cwibs
Clanguage i have to modify the given code to repeat the same problem but use only one queue for all the jobs and execute it for 100 iterations and print out the results. #include< stdio. h>
int main()
{
int queuea[100],queueb[100],queuec[100] ,lpa=0,lpb=0,lpc=0,upa=0,upb=0,upc= 0,joba=0,jobb=0,jobc=0,parta=0,part b=0,partc=0,i, j;
for(i=0; i< =100; i++)
{
int n=rand()%200+1; //generates random no between 0 to 200
if(n> =0& & n< =49) //if value of n is between 0 to 49 then executes
{
if(n> =0& & n< =25) //if value of n is between 0 to 25 then executes
{
upa++; //increment upa by 1
queuea[upa]=n; //insert value of n at index upa in queuea
parta=1; //set parta 1
}
else if(n> =26& & n< =39) //if value of n is between 26 to 39 then executes
{
upb++; //increment upb by 1
queueb[upb]=n; //insert value of n at index upb in queueb
partb=1; //set partb 1
}
else if(n> =40& & n< =49) //if value of n is between 40 to 49 then executes
{
upc++; //increment upc by 1
queuec[upc]=n; //insert value of n at index upc in queuec
partc=1; //set partc 1
}
}
else if(n> =50& & n< =100) //if value of n is between 50 to 100 then executes
{
if(n> =50& & n< =75) //if value of n is between 50 to 75 then executes
{
queuea[lpa]=0; //set index lpa in queuea 0
lpa++; //increment lpa by 1
joba++; //increment joba by 1
parta=0; //set parta 0
}
else if(n> =76& & n< =89) //if value of n is between 76 to 89 then executes
{
queueb[lpb]=0; //set index lpb in queueb 0
lpb++; //increment lpb by 1
jobb++; //increment jobb by 1
partb=0; //set partb 0
}
else if(n> =90& & n< =100) //if value of n is between 90 to 100 then executes
{
queuec[lpc]=0; //set index lpc in queuec 0
lpc++; //increment lpc by 1
jobc++; //increment jobc by 1
partc=0; //set partc 0
}
}
if(i%5==0) //if i is divisable by 5 then it executes
{
printf("\n");
printf("\nqueue a current state-");
for(j=lpa; j< =upa; j++)
{
printf("%d\t",queuea[j]); //prints all the value between range lpa to upa in queuea
}
printf("\nqueue b current state-");
for(j=lpb; j< =upb; j++)
{
printf("%d\t",queueb[j]); //prints all the value between range lpb to upb in queueb
}
printf("\nqueue c current state-");
for(j=lpc; j< =upc; j++)
{
printf("%d\t",queuec[j]); //prints all the value between range lpc to upc in queuec
}
if(parta==0) //if value of parta is 0 then display a is empty
printf("\npartion a is empty.");
else
printf("\npartion a is not empty.");
if(partb==0) //if value of partb is 0 then display b is empty
printf("\npartion b is empty.");
else
printf("\npartion b is not empty.");
if(partc==0) //if value of partc is 0 then display c is empty
printf("\npartion c is empty.");
else
printf("\npartion c is not empty.");
printf("\njobs run so far is- %d",joba+jobb+jobc); //display total no of jobs run so far
}
}
return 0;
}
Answers: 3
Computers and Technology, 22.06.2019 10:00
According to alisa miller foreign news bureaus
Answers: 3
Computers and Technology, 22.06.2019 15:00
Atool that matches persoal skills qualities interests and talets to a career is called a
Answers: 1
Computers and Technology, 23.06.2019 09:00
Before you record your own voice, you should a. record other people's voices b. warm up and practice difficult names c. listen to your favorite songs d. read a transcript of a good radio news segment
Answers: 1
Computers and Technology, 23.06.2019 09:00
Which company provides a crowdsourcing platform for corporate research and development? a: mtruk b: wiki answers c: mediawiki d: innocentive
Answers: 2
Clanguage i have to modify the given code to repeat the same problem but use only one queue for all...
Arts, 07.05.2020 13:57
Social Studies, 07.05.2020 13:57
English, 07.05.2020 13:57
Mathematics, 07.05.2020 13:57
World Languages, 07.05.2020 13:57