Professional Documents
Culture Documents
Write a C/C++ program to compute average waiting time and average turnaround
time for FCFS algorithm. The program should accept arrival time and burst time as
input.
$vim 2.c
#include<stdio.h>
typedef struct proc
{ int at,bt,pr;
}P; /* Structure to Hold Information of Process */
/*at : Arrival time,bt : Burst Time, pr : Process NO */
p->at=q->at;
p->bt=q->bt;
p->pr=q->pr;
q->at=temp.at;
q->bt=temp.bt;
q->pr=temp.pr;
}
for(i=0;i<n;i++)
{ wt[i]=wt[i]-proc[i].at; //Substract Arrival time
awt+=wt[i];
}
awt=awt*1.0/n; // Average : Divide sum by no of process
for(i=0;i<n;i++)
{ tat[i]=wt[i]+proc[i].bt; // Turn Around Time , i.e TAT=WT+BT
atat+=tat[i];
}
atat=atat*1.0/n; // Average : Divide sum by no of process
/*===========================Out_put=================================*/
$cc 2.c
$ ./a.out
2 0 3 0 3
0 3 5 0 5
3 4 7 4 11
1 6 4 9 13
_______________________________________
/*==================================================================*/