forked from ambujraj/hacktoberfest2018
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FCFS.CPP
41 lines (35 loc) · 793 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
36
37
38
39
40
41
#include<stdio.h>
#include<conio.h>
void TurnArroundTime(int arr[],int p)
{ int j=0;
int max;
int tat=0;
int wt=0;
float totaltat=0,totalwt=0;
for(j;j<p;j++)
{
tat=tat+arr[j];
printf("The TurnAround time for p%d is %d\n",j,tat);
wt=tat-arr[j];
printf("The WaitingTime for p%d is %d\n\n",j,wt);
totalwt=wt+totalwt;
totaltat=tat+totaltat;
}
printf("The Average turn around time = %f\n",totaltat/p);
printf("The Average Waiting time = %f\n",totalwt/p);
}
void main()
{ int p;
printf("THE IMPLEMENTATION OF FCFS SYSTEM OF PROCESSING\n\n");
printf("Enter number of processes ");
scanf("%d",&p);
int arr[50];
printf("Enter Burst time for each process \n");
for(int i=0;i<p;i++)
{
scanf("%d",&arr[i]);
}
TurnArroundTime(arr,p);
getch();
clrscr();
}