Untitled

 avatar
unknown
plain_text
a year ago
649 B
4
Indexable
#include<stdio.h>
void main()
{
int n,bt[50],tt[50],i,wt[50];
float ttt=0,twt=0,awt=0,att=0;
printf("enter the no of process :");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("enter the burst time of process p%d :",i);
scanf("%d",&bt[i]);
}
wt[0]=0;
tt[0]=bt[0];
for(i=1;i<n;i++)
{
wt[i]=wt[i-1]+bt[i-1];
tt[i]=bt[i]+wt[i];
}
for(i=0;i<n;i++)
{
twt=twt+wt[i];
ttt=ttt+tt[i];
}
awt=twt/n;
att=ttt/n;
printf("process\tburst time\twaiting time\tturnaround time\n");
for(i=0;i<n;i++)
{
Computer science & engineeringprintf("p%d\t%d\t\t%d\t\t%d\n",i,bt[i],wt[i],tt[i]);
}
printf("average waiting time =%f\n",awt);
printf("average waiting time =%f\n",att);
}
Editor is loading...
Leave a Comment