FCFS
#include<stdio.h>
#include<conio.h>
#include<process.h>
void main()
{
char p[10][5];
int tot=0,wt[10],pt[10],z,n,i;
float avg=0;
printf("\nenter number of process :");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\nenter process %d name : ",i+1);
scanf("%s",&p[i]);
printf("enter process time : ");
scanf("%d",&pt[i]);
}
wt[0]=0;
for (i=1;i<n;i++)
{
wt[i]=wt[i-1]+pt[i-1];
tot=tot+wt[i];
}
avg=(float)tot/n;
printf("\np-name\tp-time\tw-time \n");
for (i=0;i<n;i++)
printf("%s\t%d\t%d\n",p[i],pt[i],wt[i]);
printf("\n total waiting time : %d \n avg wating time : %f \n\n ",tot ,avg);
getch();
}
No comments:
Post a Comment