1) Write A C Program To Implement First Come First Serve (FCFS) Algorithm Program
1) Write A C Program To Implement First Come First Serve (FCFS) Algorithm Program
1) Write A C Program To Implement First Come First Serve (FCFS) Algorithm Program
PROGRAM:/* FCFS */
#include<stdio.h>
void main()
int i,j,n,b[10],p[10],w[10],t[10];
float tw=0,tt=0,avgw,avgt;
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&p[i]);
scanf("%d",&b[i]);
b[0]=0,w[0]=0;
for(i=1;i<=n;i++)
w[i]=w[i-1]+b[i-1];
tw=tw+w[i];
t[i]=w[i]+b[i];
tt=tt+t[i];
avgw=tw/n;
avgt=tt/n;
for(i=1;i<=n;i++)
PROGRAM:/* SJF */
#include<stdio.h>
int main()
int n,j,temp,temp1,temp2,pr[10],b[10],t[10],w[10],p[10],i;
float att=0,awt=0;
for(i=0;i<10;i++)
b[i]=0;w[i]=0;
}
printf("enter the number of process");
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&b[i]);
p[i]=i;
for(i=0;i<n;i++)
for(j=i;j<n;j++)
if(b[i]>b[j])
temp=b[i];
temp1=p[i];
b[i]=b[j];
p[i]=p[j];
b[j]=temp;
p[j]=temp1;
}
w[0]=0;
for(i=0;i<n;i++)
w[i+1]=w[i]+b[i];
for(i=0;i<n;i++)
t[i]=w[i]+b[i];
awt=awt+w[i];
att=att+t[i];
awt=awt/n;
att=att/n;
for(i=0;i<n;i++)
return 1;
PROGRAM: /* priority */
#include<stdio.h>
void main()
{
int i,j,n,b[10],p[10],w[10],t[10],pr[10];
float tw=0,tt=0,avgw,avgt,temp1,temp2,temp3;
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%d",&p[i]);
scanf("%d",&b[i]);
scanf("%d",&pr[i]);
for(i=1;i<=n;i++)
for(j=i+1;j<=n;j++)
if(pr[i]>=pr[j])
temp1=b[i];
b[i]=b[j];
b[j]=temp1;
temp2=p[i];
p[i]=p[j];
p[j]=temp2;
temp3=pr[i];
pr[i]=pr[j];
pr[j]=temp3;
b[0]=0,w[0]=0;
for(i=1;i<=n;i++){
w[i]=w[i-1]+b[i-1];
tw=tw+w[i];
t[i]=w[i]+b[i];
tt=tt+t[i];
avgw=tw/n;
avgt=tt/n;
for(i=1;i<=n;i++){
#include<stdio.h>
void main()
int st[10],bt[10],wt[10],tat[10],n,tq;
int i,count=0,swt=0,stat=0,temp,sq=0;
float awt=0.0,atat=0.0;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&bt[i]);
st[i]=bt[i];
scanf("%d",&tq);
while(1)
for(i=0,count=0;i<n;i++)
temp=tq;
if(st[i]==0)
count++;
continue;
if(st[i]>tq)
st[i]=st[i]-tq;
else
if(st[i]>=0)
temp=st[i];
st[i]=0;
sq=sq+temp;
tat[i]=sq;
if(n==count)
break;
for(i=0;i<n;i++)
wt[i]=tat[i]-bt[i];
swt=swt+wt[i];
stat=stat+tat[i];
}
awt=(float)swt/n;
atat=(float)stat/n;
for(i=0;i<n;i++)