-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathfcfs.c
More file actions
36 lines (35 loc) · 758 Bytes
/
fcfs.c
File metadata and controls
36 lines (35 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//CODED BY AVI 11911037
#include<stdio.h>
#include<conio.h>
#define max 30
int main()
{
int i,j,n,bt[max],wt[max],tat[max];
float awt=0,atat=0;
printf("Enter the number of process: ");
scanf("%d",&n);
printf("Enter the burst time of the process: ");
for (i = 0; i < n; ++i)
{
scanf("%d",&bt[i]);
}
printf("process\t burst time\t waiting time\t turn around time\n");
for (i = 0; i <n; ++i)
{
wt[i]=0;
tat[i]=0;
for(j=0;j<i;j++)
{
wt[i]=wt[i]+bt[j];
}
tat[i]=wt[i]+bt[i];
awt=awt+wt[i];
atat=atat+tat[i];
printf("%d\t%d\t\t%d\t\t%d\n",i+1,bt[i],wt[i],tat[i]);
}
awt=awt/n;
atat=atat/n;
printf("Average waiting time= %f \n",awt);
printf("Average turnaround time= %f",atat);
return 0;
}