-
Notifications
You must be signed in to change notification settings - Fork 0
/
FCFS.cpp
35 lines (33 loc) · 992 Bytes
/
FCFS.cpp
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
#include <iostream>
using namespace std;
int main()
{
int n, wt[100], tat[100], b[100], awt = 0, atat = 0;
cout << "Enter the number of process: ";
cin >> n;
cout << "\nEnter process burst time: " << endl;
for (int i = 0; i < n; i++)
{
cout << "P[" << i + 1 << "]: ";
cin >> b[i];
wt[i] = 0;
}
for (int i = 1; i < n; i++)
wt[i] = wt[i - 1] + b[i - 1];
cout << "\nProcess\t\tBurst Time\t\tWaiting Time\t\tTurnaround Time";
for (int i = 0; i < n; i++)
{
tat[i] = wt[i] + b[i];
awt += wt[i];
atat += tat[i];
cout << "\nP[" << i + 1 << "]"
<< "\t\t" << b[i] << "\t\t\t" << wt[i] << "\t\t\t\t" << tat[i];
}
cout << "\nWaiting Time is: " << awt << endl;
cout << "Turn Around Time is: " << atat << endl;
awt /= n;
atat /= n;
cout << "Average Wating Time is: " << awt << endl;
cout << "Average Turn Around Time is: " << atat << endl;
return 0;
}