0% found this document useful (0 votes)
10 views1 page

Program 9: Linked File Allocation Simulation

Uploaded by

sumukhchavan6
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

Program 9: Linked File Allocation Simulation

Uploaded by

sumukhchavan6
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Program 9: Develop a C program to simulate the Linked file allocation strategies.

#include<stdio.h>
int main()
{
int f[50],p,i,j,k,a,st,len,n,c;

for(i=0;i<50;i++) f[i]=0;
printf("Enter How Many Blocks That Are Already Allocated:");
scanf("%d",&p);

printf("\nEnter Blocks Numbers That Are Already Allocated:");


for(i=0;i<p;i++)
{
scanf("%d",&a);
f[a]=1;
}

X:
printf("Enter Starting Index Block & Length:");
scanf("%d%d",&st,&len);
k=len;

for(j=st;j<(k+st);j++)
{
if(f[j]==0)
{
f[j]=1;
printf("\n%d-->%d",j,f[j]);
}
else
{
printf("\n %d->file is already allocated",j);
k++;
}
}

printf("\n Want to Enter one more file? (yes-1/no-0)");


scanf("%d",&c);
if(c==1)
goto X;
}

Output:

Enter How Many Blocks That Are Already Allocated:3

Enter Blocks Numbers That Are Already Allocated:1 3 5

Enter Starting Index Block & Length:2 4

You might also like