C progrma – First Come First Serve Algorithm

by Nideesh C on April 17, 2011 · 0 comments

in C Programming




#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();
}



Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. C program – Priority Scheduling
  2. C program – Shortest Job Next
  3. C program to accept a list of data items and find the second largest and second smallest elements in it. And also computer the average of both. And search for the average value whether it is present in the array or not. Display appropriate message on successful search.
  4. C program – Round Robin
  5. C program to accept the height of a person in centimeter and categorize the person based on height as taller, dwarf and average height person

Leave a Comment

Previous post:

Next post: