fork download
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int n,m[20],i,j,sb[20],s[20],b[20][20],x;
  5.  
  6. printf("Enter no. of files:");
  7. scanf("%d",&n);
  8. for(i=0;i<n;i++)
  9. { printf("Enter starting block and size of file%d:",i+1);
  10. scanf("%d%d",&sb[i],&s[i]);
  11. printf("Enter blocks occupied by file%d:",i+1);
  12. scanf("%d",&m[i]);
  13. printf("enter blocks of file%d:",i+1);
  14. for(j=0;j<m[i];j++)
  15. scanf("%d",&b[i][j]);
  16. } printf("\nFile\t index\tlength\n");
  17. for(i=0;i<n;i++)
  18. {
  19. printf("%d\t%d\t%d\n",i+1,sb[i],m[i]);
  20. }printf("\nEnter file name:");
  21. scanf("%d",&x);
  22. i=x-1;
  23. printf("Index is:%d",sb[i]);
  24. printf("Block occupied are:");
  25. for(j=0;j<m[i];j++)
  26. printf("%d",b[i][j]);
  27.  
  28. }
Success #stdin #stdout 0s 5308KB
stdin
2
2 5
10
3 
2 5 4 6 7 2 6 4 7
3 4
5 
2 3 4 5 6 
10

stdout
Enter no. of files:Enter starting block and size of file1:Enter blocks occupied by file1:enter blocks of file1:Enter starting block and size of file2:Enter blocks occupied by file2:enter blocks of file2:
File	 index	length
1	2	10
2	3	5

Enter file name:Index is:5222Block occupied are: