Hanochsunil / lab

0 stars 0 forks source link

ROUND ROBIN #6

Open Hanochsunil opened 2 months ago

Hanochsunil commented 2 months ago

include

void main() { int i,j,done,total=0,qt,n; int tat[10],wt[10],bt[10],rem[10],p[10]; float awt=0,att=0; printf("Enter the no process"); scanf("%d",&n); printf("Enter the burst time"); for(i=0;i<n;i++) { scanf("%d",&bt[i]); rem[i]=bt[i]; p[i]=i+1; } printf("Enter the no process"); scanf("%d",&qt); while(1) { done=1; for(i=0;i<n;i++) { if(rem[i]>0) { done=0; if(rem[i]>qt) { total+=qt; rem[i]=rem[i]-qt; } else { total+=rem[i]; wt[i]=total-bt[i]; rem[i]=0; tat[i]=total; } } } if(done==1) { break; }

}

printf("Process Burst Time Waiting Time Turnaround Time\n"); for(i = 0; i < n; i++) { att += tat[i]; awt += wt[i]; printf("%d %d %d %d\n", p[i], bt[i], wt[i], tat[i]); } awt = awt / n; att = att / n; printf("Average Waiting Time: %f\n", awt); printf("Average Turnaround Time: %f\n", att); }