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 06:20
Which text function capitalizes the first letter in a string of text? question 10 options: upper capital first proper
Answers: 1
question
Computers and Technology, 24.06.2019 09:50
Create a string list. 2. use console.readline() to collect values of firstname, lastname, street, city, state, zip, save them to list. 3. write a simple linq statement, call method uppercasewords() to change first letter to uppercase. 4. create a foreach statment to display the information. public static string uppercasewords(string value) { char[] array = value.tochararray(); if (array.length > = 1) { if (char.islower(array[0])) { array[0] = char.toupper(array[0]); } } for (int i = 1; i < array.length; i++) { if (array[i - 1] == ' ') { if (char.islower(array[i])) { array[i] = char.toupper(array[i]); } } } return new string(array);
Answers: 3
question
Computers and Technology, 24.06.2019 17:40
The value of sin(x) (in radians) can be approximated by the alternating infinite series create a function (prob3_2) that takes inputs of a scalar angle measure (in radians) and the number of approximation terms, n, and estimates sin(x). do not use the sin function in your solution. you may use the factorial function. though this can be done without a loop (more efficiently), your program must use (at least) one. you may find the mod() function useful in solving the problem.
Answers: 1
question
Computers and Technology, 24.06.2019 19:00
Which of the following "invisible" marks represents an inserted tab?
Answers: 1
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
Social Studies, 30.08.2019 11:30
question
Mathematics, 30.08.2019 11:30
question
Business, 30.08.2019 11:30
Questions on the website: 13722367