Best
Best
h> temp=b[j]-p[i];
void main() if(temp>=0)
{ if(low>temp)
int {
fragment[20],b[20],p[20],i,j,nb,np,temp,low=9 parray[i]=j;
999; low=temp;
static int barray[20],parray[20]; }
printf("Memory management scheme-Best }
Fit\n"); }
printf("Enter the no. of processes:"); fragment[i]=low;
scanf("%d",&np); barray[parray[i]]=1;
printf("Enter the no. of blocks:"); low=10000;
scanf("%d",&nb); }
printf("Enter the size of the blocks:"); printf("Process no.\tProcess size\tBlock
for(i=1;i<=nb;i++) no.\tBlocksize\tFragment\n");
{ for(i=1;i<=np&&parray[i]!=0;i++)
printf("Block no. % d:",i); printf("%d\t\t%d\t\t%d\t\t%d\t\t%d\n",i,p[i],
scanf("%d",&b[i]); parray[i],b[parray[i]],fragment[i]);
} }
printf("Enter the size of the processes: ");
for(i=1;i<=np;i++) OUTPUT
{ Memory management scheme-Best Fit
printf("Process no. %d:",i); Enter the no. of processes:3
scanf("%d",&p[i]); Enter the no. of blocks:3
} Enter the size of the blocks:Block no. 1:100
for(i=1;i<=np;i++) Block no. 2:150
{ Block no. 3:200
for(j=1;j<=nb;j++) Enter the size of the processes: Process no.
{ 1:80
if(barray[j]!=1) Process no. 2:120
{ Process no. 3:180