a list to store processes is used in this program, is it a queue or a general-purpose list? #include int main() { int ace, x[10], y[10], z[10], avgy = 0, one, two; int avgz = 0; printf("Enter total number of processes: "); scanf("%d",&ace); printf("\nEnter burst times\n"); printf("\ncalculating burst time"); for(one = 0; one
a list to store processes is used in this
#include<stdio.h>
int main()
{
int ace, x[10], y[10], z[10], avgy = 0, one, two;
int avgz = 0;
printf("Enter total number of processes: ");
scanf("%d",&ace);
printf("\nEnter burst times\n");
printf("\ncalculating burst time");
for(one = 0; one<ace; one++)
{
printf("p[%d]",one+1);
scanf("%d", &x[one]);
}
y[0] = 0;
for(one = 0; one < ace; one++)
{
y[one] = 0;
for(two = 0; two < one; two++)
{
y[one] += x[two];
}
}
printf("\nProcess\tBurst Time\tWaiting Time\tTurnaround time");
for(one = 0; one < ace; one++)
{
z[one] = x[one] + y[one];
avgy += y[one];
avgz += z[one];
printf("\n[%d]\t\t%d\t\t%d\t\t%d",one+1,x[one],y[one],z[one]);
}
printf("\nAverage waiting time: %f\nAverage turn around time: %f", (float)avgy/one,(float)avgz/one);
return 0;
}
Step by step
Solved in 2 steps with 2 images