Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- void main()
- {
- int bt[20], wt[20], tat[20], i, n, p[20], temp=0, k;
- float wtavg, tatavg, watag;
- printf ("Enter the no. of process: ");
- scanf("%d",&n);
- for(i=0; i<n; i++)
- {
- p[i]=i;
- printf ("Enter burst time for process %d: ", i);
- scanf ("%d", &bt[i]);
- }
- for (i=0; i<n; i++)
- {
- for(k=i+1; k<n; k++)
- {
- if(bt[i]>bt[k])
- {
- temp=bt[i];
- bt[i]=bt[k];
- bt[k]=temp;
- temp=p[i];
- p[i]=p[k];
- p[k]=temp;
- }
- }
- }
- wt[0] = 0;
- tat[0] = bt[0];
- for(i=0; i<=n; i++)
- {
- wt[i]=tat[i-1];
- tat[i]= wt[i]+bt[i];
- }
- printf("\t Process \t Burst Time \t Waiting Time \t TurnaroundT");
- for(i=0; i<n; i++)
- {
- printf("\n\t p%d \t\t%d \t\t%d \t\t%d", p[i], bt[i], wt[i], tat[i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement