Resources » Education

FIRST COME FIRST SERVE program in C


Updated: Category: Education
Author: Member Level: SilverPoints: 2


This is the implementation of fcfs (first come first serve) algorithm in C language.



#include
#include
void main( )
{
char pname[10][20];
float b_time[10],wt_time[10],avg_time[10],s,t_time[10],k, t=0;
int i,n;
clrscr( );
printf("enter the total no. of processes: ");
scanf("%d",&n);
for(i=0;i {
printf("\nenter process name:");
scanf("%s",pname[i]);
printf("enter burst time ");
scanf("%f",&b_time[i]);
}
for(i=0;i {
if(i==0)
{
wt_time[i]=0;avg_time[i]=0;
}
else
{
wt_time[i]=wt_time[i-1]+b_time[i-1];
}
t_time[i]=wt_time[i]+b_time[i];
t+=t_time[i];
}
k=t/n;
for(i=1;i {
avg_time[i]=avg_time[i-1]+wt_time[i];
}
s=avg_time[n-1]/n;
printf("\n pr.no\t pr.name\t b_time\t wt_time\tt_time\n");
for(i=0;i {
printf("%d\t\t%s\t%f\t%f\t%f\n",i+1,pname[i],b_time[i],wt_time[i],t_time[i]);
}
printf("average waiting time:%f\naverage turn around time: %f\n",s,k);
getch( );
}


Did you like this resource? Share it with your friends and show your love!




Responses to "FIRST COME FIRST SERVE program in C"
Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Submit Article     Return to Article Index
    Complete the action items below to enter to win an iPad Mini from India Study Channel! in India Study Channel - Locker on LockerDome
    Awards & Gifts
    Active Members
    TodayLast 7 Daysmore...

     
    ISC Technologies, Kochi - India. © All Rights Reserved.