Tuesday , December 6 2016
Home / C / c program for Best fit memory segment

c program for Best fit memory segment


C program for best fit memory segment.

#include
#include
void main()
{
int i,j,mem[30],n,pro[30],m,temp,k,avail[5],t;
clrscr();
printf(“\n enter the no. of partition of memory:”);
scanf(“%d”,&n);
printf(“\n partitions in memory:”);
for(i=0;i
{

scanf(“%d”,&mem[i]);
}
printf(“\n enter the no of process to be placed in memory:”);
scanf(“%d”,&m);
printf(“\n processes are:”);
for(j=0;j
scanf(“%d”,&pro[j]);

for(i=0;i
{
t=i;
for(j=i+1;j
{
if(mem[t]>mem[j])
{
temp=mem[j];
mem[j]=mem[t];
mem[t]=temp;
}
}
}
for(i=0;i
{
printf(“\n processe are: %d”,mem[i]);
}
for(i=0;i
{
for(j=0;j
{
if(pro[i]<=mem[j])
{
printf(“\n the process %dk is placed in memory %dk”,pro[i],mem[j]);
k=j;
mem[k]=0;
avail[i]=pro[i];
break;
}
}
}
for(i=0;i
{
if(pro[i]!=avail[i])
{
printf(“\n the process %dk cannot be placed”,pro[i]);
}
}
getch();
}


OUTPUT:

Tags: program in c fro best fir memory segments, memory segment program for best fit, c program for best fit memory segment.

Also See:   C program to add two numbers using recursion method

Check Also

Hide Mouse Pointer C Program

How to Hide a Mouse Pointer Program in C : This program will show and hide ...

Leave a Reply

Your email address will not be published. Required fields are marked *

Preventing spam * Time limit is exhausted. Please reload the CAPTCHA.