Skip to content

Commit

Permalink
Create FCFS.c
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnoldAldrin committed Aug 29, 2022
1 parent bd3539c commit ca8bc12
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions FCFS.c
@@ -0,0 +1,36 @@
#include<stdio.h>
int main()
{
int n,j,i;
printf("Enter the no. of processes:");
gets();
int a[n],bt[n],tat[n],wt[n],ct[n],at[n];
float awt,wts=0;
printf("enter burst time:");
for(i=0;i<n;i++)
scanf("%d",&bt[i]);
printf("enter arrival time:");
for(i=0;i<n;i++)
scanf("%d",&at[i]);
for(i=0;i<n;i++)
a[i]=i+1;
ct[0]=bt[0];
for(i=1;i<n;i++)
ct[i]=ct[i-1]+bt[i];
for(i=0;i<n;i++)
tat[i]=ct[i]-at[i];
for(i=0,j=0;i<n;i++,j++)
wt[i]=tat[i]-bt[j];
printf("\nprocess\tBT\tAT\tCT\tTAT\tWT");
for(i=0;i<n;i++)
{
printf("\nP%d\t%d\t%d\t%d\t%d\t%d",a[i],bt[i],at[i],ct[i],tat[i],wt[i]);
}
for(i=0;i<n;i++)
{
wts=wts+wt[i];
}
awt=wts/n;
printf("\naverage waiting time:%f",awt);
return 0;
}

0 comments on commit ca8bc12

Please sign in to comment.