#include<stdio.h>
#include<conio.h>
#include<process.h>
int main()
{
int n,i,burst[100],awt=0,twt=0,waiting[100];
printf("Enter number of processes");
scanf("%d",&n);
printf("Enter burst time");
for(i=0;i<n;i++)
{
scanf("%d",&burst[i]);
}
waiting[0]=0;
for(i=1;i<n;i++)
{
waiting[i]=waiting[i-1]+burst[i-1];
twt=twt+waiting[i];
}
printf("\ntotal waiting time=%d",twt);
awt=twt/n;
printf("\nAverage waiting time=%d",awt);
getch();
}
#include<conio.h>
#include<process.h>
int main()
{
int n,i,burst[100],awt=0,twt=0,waiting[100];
printf("Enter number of processes");
scanf("%d",&n);
printf("Enter burst time");
for(i=0;i<n;i++)
{
scanf("%d",&burst[i]);
}
waiting[0]=0;
for(i=1;i<n;i++)
{
waiting[i]=waiting[i-1]+burst[i-1];
twt=twt+waiting[i];
}
printf("\ntotal waiting time=%d",twt);
awt=twt/n;
printf("\nAverage waiting time=%d",awt);
getch();
}
No comments:
Post a Comment