#include<stdio.h>
#include<malloc.h>
main ()
{
int i,n;
float wt=0,bt=0,awt=0,x,abt=0;
puts("Enter the no. of processes");
scanf("%d",&n);
float a[n],b[n];
puts("Enter the arrival and burst time with space separated values");
for(i=0;i<n;i++)
scanf("%f%f",&a[i],&b[i]);
puts("Process\tArrival Time\tBurst Time");
for(i=0;i<n;i++)
printf("P[%d]\t%f\t%f\n",i+1,a[i],b[i]);
x=a[0];
for(i=0;i<n;i++)
{
wt=x-a[i];
awt=awt+wt;
x=x+b[i];
abt=abt+(x-a[i]);
}
awt=awt/n;
abt=abt/n;
printf("Average Waiting Time = %f \nAverage Burst Time = %f",awt,abt);
}
Comments
Post a Comment