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();
} |
#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();
}
Editorial Team
We are a group of young techies trying to provide the best study material for all Electronic and Computer science students. We are publishing Microcontroller projects, Basic Electronics, Digital Electronics, Computer projects and also c/c++, java programs.
I can not compile… there is some C program in specific. to compile.
tks..
Can you help me with Last Come, First Served (LCFS) or Last In, First Out (LIFO)
C program codes? Please. Many Thanks! 🙂
its too long code….i want to much of shortest code of fcfs…
output is not yet cmg…..
How do you code this using a Circular Queue implemented by Arrays?
there is an Declaration problem in your prog.
correct your prog.There is an Declaration problem in your prog.
will not be run at c editor.