Thursday, 1 November 2018

LINKED FILE ALLOCATION

#include <stdio.h>
int main(){
int a1[50],i=0,j=0,k=0,nb=0,st=0,l=0,te=0;
for(i=0;i<50;i++)
a1[i]=0;
printf("Enter how many blocks already allocated\n");
scanf("%d",&l);
printf("Enter the block numbers\n");
for(i=0;i<l;i++){
scanf("%d",&j);
a1[j]=1;
}
do{
k=0;
printf("Enter start block number and length of file in blocks: \n");
scanf("%d%d",&st,&nb);
k=nb;
for(i=st;i<(st+k);i++){
if(a1[i]==0){
a1[i]=1;
printf("%d-->%d\n",i,1);
te++;}
else{
k++;
printf("%d is ALready occupied block\n",i);
}
}
if(te==0&&k==nb){
printf("File cannot be allocated\n");
}
printf("Do you want to continue to insert another file\n1.YES\t 2.NO\n");
scanf("%d",&i);
}while(i==1);
return 0;
}



No comments:

Post a Comment

FERMATS LITTLE THEOREM

import java.math.*; import java.io.*; import java.util.Scanner; public class Main { public static void main(String[] args) {    Sca...