fork download
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int n,i,j,b[20],sb[20],t[20],x,c[20][20];
  5. printf("Enter no.of files:");
  6. scanf("%d",&n);
  7. for(i=0;i<n;i++)
  8. {
  9. printf("Enter no. of blocks occupied by file%d",i+1);
  10. scanf("%d",&b[i]);
  11. printf("Enter the starting block of file%d",i+1);
  12. scanf("%d",&sb[i]);
  13. t[i]=sb[i];
  14. printf("\n abc");
  15. for(j=0;j<b[i];j++) {
  16. c[i][j]=sb[i]++;
  17.  
  18. printf("%d ",c[i][j]);}
  19. printf("\n");
  20. }
  21. printf("Filename\tStart block\tlength\n");
  22. for(i=0;i<n;i++)
  23. printf("%d\t %d \t%d\n",i+1,t[i],b[i]);
  24. printf("Enter file name:");
  25.  
  26. scanf("%d",&x);
  27.  
  28. printf("length is:%d",b[x-1]);
  29. printf("blocks occupied:");
  30. for(i=0;i<b[x-1];i++)
  31. printf("%d ",c[x-1][i]);
  32. }
Success #stdin #stdout 0s 5300KB
stdin
2
4
2
10
5
5
stdout
Enter no.of files:Enter no. of blocks occupied by file1Enter the starting block of file1
 abc2 3 4 5 
Enter no. of blocks occupied by file2Enter the starting block of file2
 abc5 6 7 8 9 10 11 12 13 14 
Filename	Start block	length
1	 2 	4
2	 5 	10
Enter file name:length is:0blocks occupied: