Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int n, i, j, burst[10], wait[10],turn[10], avgWait = 0;
- printf("Enter the no. of process: ");
- scanf("%d",&n);
- for(int i = 0; i < n;)
- {
- printf("Enter the burst time for process#%d: ",i+1);
- scanf("%d",&burst[i++]);
- }
- //get waiting time
- wait[0] = 0;
- for(i = 1;i < n; i++)
- {
- wait[i] = 0;
- for(j = 0;j < i; j++)
- wait[i] += burst[j];
- }
- printf("\nProcess\t\tBurst Time\tWaiting Time\tTurnaround Time");
- for(i = 0;i < n; i++)
- {
- turn[i] = burst[i] + wait[i];
- avgWait += wait[i];
- printf("\nProcess %d\t\t%d\t\t%d\t\t%d", i+1, burst[i], wait[i], turn[i]);
- }
- printf("\nAverage = %d",avgWait / i);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement