#include<stdio.h>
#include<conio.h>
void main()
{
int st[5],wt[5]={0,0,0,0,0},trt[5]={0,0,0,0,0},i;
float tot_trt=0,tot_wt=0;
clrscr();
printf("Enter the service time of each
process\n");
for(i=0;i<5;i++)
{
scanf("%d",&st[i]);
}
//trt[0]=0;
//wt[0]=0;
for(i=0;i<5;i++)
{
trt[i]=wt[i]+st[i];
wt[i+1]=trt[i];
}
for(i=0;i<5;i++)
{
tot_trt=tot_trt+trt[i];
tot_wt=tot_wt+wt[i];
}
tot_trt=tot_trt/5;
tot_wt=tot_wt/5;
for(i=0;i<5;i++)
{
printf("\nTurn Around Time of each process is
%d and waiting time of each process %d\n",trt[i],wt[i]);
}
printf("\nTotal turn around time is %d and
Total Waiting time is %d\n",tot_trt,tot_wt);
getch();
}
No comments:
Post a Comment