subject
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;
}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 10:00
Hey i just logged on and one of the moderators deleted a bunch of my answers to questions, even though the answers were right and the people it doesn't make sense but if anyone wants to talk about anything just message me lol (this is super random lol)
Answers: 1
question
Computers and Technology, 24.06.2019 13:30
Write a program that uses a two-dimensional array to store the highest and lowest temperatures for each month of the year. the program should output the average high, average low, and the highest and lowest temper- atures for the year. your program must consist of the following functions: a. function getdata: this function reads and stores data in the two- dimensional array. b. function averagehigh: this function calculates and returns the average high temperature for the year. c. function averagelow: this function calculates and returns the aver- age low temperature for the year. d. function indexhightemp: this function returns the index of the highest high temperature in the array. e. function indexlowtemp: this function retur
Answers: 3
question
Computers and Technology, 24.06.2019 16:00
"gps interaction and cognitive process" respond to the following: imagine that you have been asked to design a gps product that will have voice recognition and bluetooth capability. discuss and conceptualize a user interaction model. predict two (2) problems that may arise in gps products with voice recognition and bluetooth capability. recommend solutions for each of these issues. attention is one of the six cognition processes. when attention is applied to a design, the goal is to make it easier for the end user to quickly locate where he / she should type information on the computer or mobile device screen. compare and contrast how the google search engine and the microsoft bing search engine employ the attention cognition process. provide your opinion as to which search engine better employs the attention cognition process and explain why.
Answers: 3
question
Computers and Technology, 24.06.2019 22:00
Aobject is used for displaying the results of a question based on stored data. a. query b. report c. table d. form
Answers: 2
You know the right answer?
Clanguage i have to modify the given code to repeat the same problem but use only one queue for all...
Questions
question
Advanced Placement (AP), 09.07.2019 03:30
question
World Languages, 09.07.2019 03:30
question
Physics, 09.07.2019 03:30
Questions on the website: 13722362