#include void main() { int n,temp,temp1,temp2,pro[20],bt[20],at[20],tat[20],fwt[20],wt[20],i,j; int wtt=0,tt=0; int avgtt,avgwtt; printf("Enter the no of process \n"); scanf("%d",&n); printf("\n Process\tbursttime\tArrivaltime\n"); for(i=0;iscanf("%d\t%d\t%d",&pro[i],&bt[i],&at[i]); for(i=0;i{ for(j=i+1;j{ if(at[i]>at[j]) { temp=at[i]; at[i]=at[j]; at[j]=temp; temp1=bt[i]; bt[i]=bt[j]; bt[j]=temp1; temp2=pro[i]; pro[i]=pro[j]; pro[j]=temp2; } } } for(i=0;i{ if(i==0) { fwt[i]=0; } else { fwt[i]=fwt[i-1]+bt[i-1]; wt[i]=fwt[i]-at[i]; } tat[i]=bt[i]+wt[i]; } for(i=0;i{ tt+=tat[i]; wtt+=wt[i]; } avgwtt=wtt/n; avgtt=tt/n; printf("\nProcess\tBursttimr\tArrivaltime\tWaitingtime\tTurnaroundtime"); for(i=0;i{ printf("\n%d\t\t%d\t\t%d\t\t%d\t\t%d\n",pro[i],bt[i],at[i],wt[i],tat[i]); } printf("Average Turnaroundtime:%d\n",avgtt); printf("Average Waitingtime:%d\n",avgwtt); }
|
No feedbacks found. Be the first to respond and make money from revenue sharing program.
|