forked from iedcbootcampcec/letshack-basic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fcfs.c
61 lines (43 loc) · 959 Bytes
/
fcfs.c
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <stdio.h>
void main()
{
int i,j,temp,n,at[25], bt[25], ct[25], tat[25],wt[25],sum=0;
float totWT=0, totTAT=0;
printf ("Enter the no: of processer: ");
scanf ("%d", &n);
for (i=0; i<n; i++)
{
printf ("\n Enter arrival time of process %d:", i);
scanf ("%d",&at[i]);
printf ("\n Enter burst time of process %d:",i);
scanf("%d",&bt[i]);
}
//CALCULATING COMPLETION TIME
for (i=0; i<n; i++)
{
sum=sum+bt[i];
ct[i]=sum;
}
//CALCULATING TURN AROUND TIME
for (i=0; i<n; i++)
{ tat[i]=ct[i]-at[i];
totTAT+=tat[i];
}
//| CALCULATING, WAITING TIME X3
for (i=0; i<n; i++)
{
wt[i]=tat[i]-bt[i];
totWT+=wt[i];
}
printf ("\n TABLE");
printf ("\n----- ");
printf ("\n\n P.No\t AT\t BT\t CT\t TAT\t WT");
for (i=0; i<n; i++)
{
printf ("\n P%d\t %d\t %d\t %d\t %d\t%d",i,at[i],bt[i],ct[i],tat[i],wt[i]);
}
printf ("\n Average Turn around Time: %f", (totTAT/n));
printf ("\n Average waiting Time: %f \n", totWT/n);
}
//return 0;
//OUTPUT