#include<iostream.h>
#include<conio.h>
#include<stdio.h>
struct process
{ float t ;
int i;
};
int main()
{ process p[4];
int n=4,temp;
float t[4],w[4],ta=0,wa=0;
clrscr();
for( int j=0;j<n;j++)
{ cout<<"\n enter the the burst time of process p"<<j+1<<" : ";
cin>>p[j].t; }
t[0]=p[0].t;
for(j=1;j<4;j++)
{ t[j]=t[j-1]+p[j].t;
}
for (j=0;j<4;j++)
{ w[j]=t[j]-p[j].t;
ta+=t[j];
wa+=w[j];
p[j].i=j;
}
// tubular display
cout<<"\n\n FCFS ALGO OF 4 PROCESSES \n (\"All times are in milliseconds)\n\n\n -: RESULT :-\n";
for(j=0;j<60;j++)
cout<<"-";
cout<<"\n\n PROCESS | BURSTS | TAT | WT | \n\n";
for(j=0;j<60;j++)
cout<<"-";
cout<<"\n";
for(j=0;j<4;j++)
{ cout<<" "<<p[j].i+1<<" "<<p[j].t<<" "<<t[j]<<" "<<w[j]<<endl;
for(int m=0;m<60;m++)
cout<<"-";
cout<<endl;
}
float taa=ta/4,waa=wa/4;
cout<<"\n\r AVERAGE :| "<<taa<<" "<<waa;;
cout<<endl;
for(int m=0;m<60;m++)
cout<<"-";
getch();
return 0;
}
#include<conio.h>
#include<stdio.h>
struct process
{ float t ;
int i;
};
int main()
{ process p[4];
int n=4,temp;
float t[4],w[4],ta=0,wa=0;
clrscr();
for( int j=0;j<n;j++)
{ cout<<"\n enter the the burst time of process p"<<j+1<<" : ";
cin>>p[j].t; }
t[0]=p[0].t;
for(j=1;j<4;j++)
{ t[j]=t[j-1]+p[j].t;
}
for (j=0;j<4;j++)
{ w[j]=t[j]-p[j].t;
ta+=t[j];
wa+=w[j];
p[j].i=j;
}
// tubular display
cout<<"\n\n FCFS ALGO OF 4 PROCESSES \n (\"All times are in milliseconds)\n\n\n -: RESULT :-\n";
for(j=0;j<60;j++)
cout<<"-";
cout<<"\n\n PROCESS | BURSTS | TAT | WT | \n\n";
for(j=0;j<60;j++)
cout<<"-";
cout<<"\n";
for(j=0;j<4;j++)
{ cout<<" "<<p[j].i+1<<" "<<p[j].t<<" "<<t[j]<<" "<<w[j]<<endl;
for(int m=0;m<60;m++)
cout<<"-";
cout<<endl;
}
float taa=ta/4,waa=wa/4;
cout<<"\n\r AVERAGE :| "<<taa<<" "<<waa;;
cout<<endl;
for(int m=0;m<60;m++)
cout<<"-";
getch();
return 0;
}