-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfcfs1.cpp
44 lines (35 loc) · 829 Bytes
/
fcfs1.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
36
37
38
39
40
41
42
43
44
#include <iostream>
using namespace std;
int main() {
cout<<"enter the no of processes that you need to execute:";
int n=4;
int bt[4];//burst time
cout<<"enter the burst time for the processes";
for(int i=0;i<n;i++){
cin>>bt[i];
}
int wt[4];
for(int i=0;i<n;i++){
if(i==0){
wt[0]=0;
}
else{
wt[i]=bt[i-1]+wt[i-1];
}
}
int tat[4];
for(int i=0;i<n;i++){
tat[i]=wt[i]+bt[i];
}
int total_wt=0;
int total_tat=0;
for(int i=0;i<n;i++){
total_wt+=wt[i];
total_tat+=tat[i];
}
float avg_wt=total_wt/n;
float avg_tat=total_tat/n;
cout<<"avg waiting time is:"<<avg_wt<<endl;
cout<<"avg turnAroundTime is:"<<avg_tat<<endl;
return 0;
}