C progrma for First Come First Serve Algorithm

Monday, March 29th, 2010

C progrma for First Come First Serve Algorithm

#include<stdio.h>
#include<math.h>
#include<conio.h>
void main()
{
      clrscr();
      int p[20],b[20],w[20],t[20],i,v,n,at;
      int wt=0;
      float tw,tr;
      printf("Enter the number of process : ");
      scanf("%d",&n);
      printf("enter CPU burst time : ");
      for(i=1;i<=n;i++)
       {
         scanf("%d",&b[i]);
         t[1]=b[1];
         w[1]=0;
         at=t[1];
         wt=w[1];
	for(i=2;i<=n;i++)
	{
	  t[i]=b[i]+t[i-1];
	  at=at+t[i];
	  w[i]=t[i-1];
	  wt=wt+w[i];
	 }
       }
      printf("process \t burst_time \t wait_time \t turn_around \t \n");
      for(i=1;i<=n;i++)
      {
         printf("%d \t\t %d \t\t %d \t\t %d",i,b[i],w[i],t[i]);
         printf("\n");
      }
      printf("\n average wait time");
      tw=wt/n;
      printf("%f",tw);
      printf("\n Average turn around time");
      tr=at/n;
      printf("%f",tr);
      getch();
}

Author Name :
Ranjith

Total : 12 Comments


12 Responses to “C progrma for First Come First Serve Algorithm”

  1. Felipe says:

    I can not compile… there is some C program in specific. to compile.

    tks..

  2. meena says:

    hey i wanted the same program using structures in c program… thank u for the basic prog

  3. honey says:

    thanxxxxxxxxxxxxxxxxxxxx
    for this
    programmmmmmm

    dili shukriya

  4. safriduo says:

    not workin !!!!

  5. vaithees says:

    dont upload the error program…….

  6. rohit says:

    hey ur program is not running plz modify this program

  7. amit says:

    hey your program is working good…..

  8. vaibhav says:

    thanks a lot for this program this is easy to understandable…………

  9. Rashu says:

    silly error…(seems silly, means a lot..!!)

    close the first “for” loop soon after “scanf” statement…
    otherwise it takes only one burst time value and remaining garbage..!!:)

  10. NeedHelpURGENT! says:

    Can you help me with Last Come, First Served (LCFS) or Last In, First Out (LIFO)
    C program codes? Please. Many Thanks! :)

  11. ankit says:

    its too long code….i want to much of shortest code of fcfs…

  12. sajisree says:

    output is not yet cmg…..

Leave a Reply

Question and Answer
C/C++ Unix & Linux Wordpress
Source codes
C C++ Java

Free email signup

Email: