Advertisement
Tusohian

First Come First Serve (FCFS)

Sep 19th, 2018
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.62 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. void main()
  4. {
  5.     int bt[20], wt[20], tat[20], i, n;
  6.     float wtavg, tatavg, watag;
  7.     printf ("Enter the no. of process: ");
  8.     scanf("%d",&n);
  9.     for(i=0; i<n; i++)
  10.     {
  11.         printf ("Enter burst time for process %d: ", i);
  12.         scanf ("%d", &bt[i]);
  13.     }
  14.  
  15.    wt[0] = 0;
  16.    tat[0] = bt[0];
  17.  
  18.    for(i=1; i<n; i++)
  19.     {
  20.         wt[i]=tat[i-1];
  21.         tat[i]= wt[i]+bt[i];
  22.     }
  23.  
  24.     printf("\t Process \t Burst Time \t Waiting Time \t TurnaroundT");
  25.  
  26.     for(i=0; i<n; i++)
  27.     {
  28.         printf("\n\t p%d \t\t%d \t\t%d \t\t%d", i, bt[i], wt[i], tat[i]);
  29.     }
  30.  
  31.  
  32.  
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement