Advertisement
fannyxmikasa

First Come First Serve Scheduling

Jan 26th, 2021
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.74 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5.     int n, i, j, burst[10], wait[10],turn[10], avgWait = 0;
  6.  
  7.     printf("Enter the no. of process:   ");
  8.     scanf("%d",&n);
  9.  
  10.     for(int i = 0; i < n;)
  11.     {
  12.         printf("Enter the burst time for process#%d:    ",i+1);
  13.         scanf("%d",&burst[i++]);
  14.     }
  15.     //get waiting time
  16.     wait[0] = 0;
  17.     for(i = 1;i < n; i++)
  18.     {
  19.         wait[i] = 0;
  20.         for(j = 0;j < i; j++)
  21.             wait[i] += burst[j];
  22.     }
  23.  
  24.     printf("\nProcess\t\tBurst Time\tWaiting Time\tTurnaround Time");
  25.     for(i = 0;i < n; i++)
  26.     {
  27.         turn[i] = burst[i] + wait[i];
  28.         avgWait += wait[i];
  29.         printf("\nProcess %d\t\t%d\t\t%d\t\t%d", i+1, burst[i], wait[i], turn[i]);
  30.     }
  31.     printf("\nAverage = %d",avgWait / i);
  32.  
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement