Thanks for visiting,stay connected for more updates !

Tuesday, August 13, 2013

First Come First Serve(FCFS) Scheduling Algorithm

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int y,b[10];
char n[10];
int w[10];
int t[10];
w[1]=0;
cout<<"Enter no. processes:";
cin>>y;
for(int i=0;i<y;i++)
{
cout<<"Enter process name:";
cin>>n[i];
cout<<"Enter burst time:";
cin>>b[i];
}
cout<<"Waiting time for p1="<<w[1]<<endl;
for(int k=2;k<=y;k++)
{
w[k]=w[k-1]+b[k-2];
cout<<endl<<"Waiting time for p"<<k<<"="<<w[k]<<endl;
}
for(int j=1;j<4;j++)
{
t[j]=w[j]+b[j-1];
cout<<endl<<"Turn around time for p" <<j<<"="<<t[j]<<endl;
}
getch();
}
Do you Like this story..?

Get Free Email Updates Daily!

Follow us!