You are on page 1of 2

Ques:-

WAP to write c-code for FCFS algorithm by taking into account the arrival time

!include"stdio h# !include"conio h# void void void void dis$lay%&' getdata%&' wait(ime%&' turnAround(ime%&'

int n) a*+,,-)b*+,,-' int main%& . $rintf%/00000 FCFS % F12S( C345 F12S( S5265 & SC7589:1;< 000000=n=n/&' getdata%&' dis$lay%&' wait(ime%&' turnAround(ime%&' getch%&'

>

void getdata%& . char c' $rintf%/5nter the number of $rocess /&' scanf%/?d/)@n&' $rintf%/=n8o you need to enter the arrival time of $rocess *yAn- or *BA;-=n/&' scanf%/?s/)@c&' for%int iC,' i"n' iDD& . $rintf%/5nter the ?d $rocess burst time : /)iD+&' scanf%/?d/)@b*i-&' if%cCCEyE FF cCCEBE& . $rintf%/5nter the ?d $rocess arrival time : /)iD+&' scanf%/?d/)@a*i-&' > else . a*i-C,' > >

>

void dis$lay%& . $rintf%/=nP23C5SS=tG92S( (145=tA2216A: (145H=n/&'

for%int iC,' i"n' iDD& . $rintf%/ ?d=t > >

?d=t

?d=n/)iD+)b*i-)a*i-&'

void wait(ime%& . int w*+,,-' float totalWaitC,' w*,-C,' for%int iC+' i"n' iDD& . w*i-Cb*i-+--a*i-Dw*i-+-' totalWaitCw*i-DtotalWait' > $rintf%/=n(otal Waiting time C ?f/)totalWait&' $rintf%/=nAverage Waiting time C ?f/)totalWait&' > void turnAround(ime%& . int tat*+,,-' float total(atC,' tat*-+-C,' for%int iC,' i"n' iDD& . tat*i-Cb*i--a*i-Dtat*i-+-' total(atCtotal(atDtat*i-' > $rintf%/=n=n(otal (urn Around (ime%(A(& C ?f/)total(at&' $rintf%/=nAverage (urn Around (ime Avg %(A(& C ?f/)total(atAn&' >

You might also like