#include
#include
void main( )
{
char pname[10][20];
float b_time[10],wt_time[10],avg_time[10],s,t_time[10],k, t=0;
int i,n;
clrscr( );
printf("enter the total no. of processes: ");
scanf("%d",&n);
for(i=0;i {
printf("\nenter process name:");
scanf("%s",pname[i]);
printf("enter burst time ");
scanf("%f",&b_time[i]);
}
for(i=0;i {
if(i==0)
{
wt_time[i]=0;avg_time[i]=0;
}
else
{
wt_time[i]=wt_time[i-1]+b_time[i-1];
}
t_time[i]=wt_time[i]+b_time[i];
t+=t_time[i];
}
k=t/n;
for(i=1;i {
avg_time[i]=avg_time[i-1]+wt_time[i];
}
s=avg_time[n-1]/n;
printf("\n pr.no\t pr.name\t b_time\t wt_time\tt_time\n");
for(i=0;i {
printf("%d\t\t%s\t%f\t%f\t%f\n",i+1,pname[i],b_time[i],wt_time[i],t_time[i]);
}
printf("average waiting time:%f\naverage turn around time: %f\n",s,k);
getch( );
}
No comments:
Post a Comment