-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFCFS.cpp
More file actions
33 lines (31 loc) · 786 Bytes
/
FCFS.cpp
File metadata and controls
33 lines (31 loc) · 786 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
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int bt[20],wt[20],tat[20],n;
float wtavg,tatavg;
cout << "Enter the number of processes:";
cin >> n;
cout << endl;
for(int i=0;i<n;i++)
{
cout << "Enter Burst time for process " << i <<":";
cin >> bt[i];
}
wt[0]=wtavg=0;
tat[0]=tatavg=bt[0];
for(int i=0;i<n;i++)
{
wt[i]=wt[i-1]+bt[i-1];
tat[i]=tat[i-1]+bt[i];
wtavg=wtavg+wt[i];
tatavg=tatavg+tat[i];
}
cout << "\n\tProcess\tBurst Time\tWaiting time\tTurn around time"<< endl;
for(int i=0;i<n;i++)
cout << "\n\tP" << i <<"\t" << bt[i] <<"\t\t" <<wt[i] <<"\t" <<tat[i];
cout << "\n\nAverage waiting time =" << wtavg/n << endl;
cout << "Average Turnaround Time =" << tatavg/n << endl;
return 0;
}