-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFCFS.c
More file actions
40 lines (33 loc) · 899 Bytes
/
Copy pathFCFS.c
File metadata and controls
40 lines (33 loc) · 899 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
37
38
39
40
#include<stdio.h>
int main()
{
int n, bt[10], wt[10], tat[10], avwt=0, avtat=0, i, j;
printf("Enter total number of processos:");
scanf("%d", &n);
printf("\nEnter process burst time:\n");
for(i=0; i<n; i++)
{
printf("p[%d]:", i+1);
scanf("%d", &bt[i]);
}
wt[0]=0;
for(i=1;i<n;i++)
{
wt[i]=0;
for(j=0; j<i; j++)
wt[i]=wt[i]+bt[j];
}
printf("\n process \t burst time \t waiting time \t turnaround time");
for(i=0; i<n; i++)
{
tat[i]=bt[i]+wt[i];
avwt=avwt+wt[i];
avtat=avtat+tat[i];
printf("\n p[%d] \t\t %d \t\t %d \t\t %d", i+1, bt[i], wt[i], tat[i]);
}
avwt=avwt/i;
avtat=avtat/i;
printf("\n\n Average waiting time: %d", avwt);
printf("\n Average turnaround time: %d", avtat);
return 0;
}