FILE_OS - 1|Page INDEXED#include<stdio.h>#include<conio.h>#include<stdlib.h> void main int f[50 index[50,i n st len j c k ind,count=0 clrscr

FILE_OS - 1|Page...

This preview shows page 1 - 4 out of 10 pages.

1 | P a g e INDEXED #include<stdio.h> #include<conio.h> #include<stdlib.h> void main() { int f[50], index[50],i, n, st, len, j, c, k, ind,count=0; clrscr(); for(i=0;i<50;i++) f[i]=0; x:printf("Enter the index block: "); scanf("%d",&ind); if(f[ind]!=1) { printf("Enter no of blocks needed and no of files for the index %d on the disk : \n", ind); scanf("%d",&n); } else { printf("%d index is already allocated \n",ind); goto x; } y: count=0; for(i=0;i<n;i++) { scanf("%d", &index[i]); if(f[index[i]]==0) count++; } if(count==n) { for(j=0;j<n;j++) f[index[j]]=1; printf("Allocated\n");
2 | P a g e printf("File Indexed\n"); for(k=0;k<n;k++) printf("%d-------->%d : %d\n",ind,index[k],f[index[k]]); } else { printf("File in the index is already allocated \n"); printf("Enter another file indexed"); goto y; } printf("Do you want to enter more file(Yes - 1/No - 0)"); scanf("%d", &c); if(c==1) goto x; else exit(0); getch(); }
3 | P a g e LINKED #include<stdio.h> #include<conio.h> #include<stdlib.h> void main() { int f[50], p,i, st, len, j, c, k, a; clrscr(); for(i=0;i<50;i++) f[i]=0; printf("Enter how many blocks already allocated: "); scanf("%d",&p); printf("Enter blocks already allocated: "); for(i=0;i<p;i++) { scanf("%d",&a); f[a]=1; }

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture