program for INDEXED algoritham using c-languge


INDEXED ALGORITHM
#include<stdio.h>
#include<conio.h>
main()
{
int sb[20],size[20],n,i,j,x;
int c[10][10];
clrscr();
printf("Enter number of files:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter index number and size of File %d:\n",i);
scanf("%d%d",&sb[i],&size[i]);
}
printf("Enter the blocks occupied by each of them: ");
for(i=0;i<n;i++)

            for(j=0;j<size[i];j++)
                        scanf("%d",&c[i][j]);
printf("\nFilename\tIndex\tsize\tBlocks-occupied\n");
for(i=0;i<n;i++)
{
            printf("\np[%d]\t\t%d\t%d\t",i,sb[i],size[i]);
for(j=0;j<size[i];j++)
            printf("%3d",c[i][j]);
}
printf("\nEnter file name:");
scanf("%d",&x);
if(x<n)
{
printf("\nBlocks of p[%d] are:",x);
for(i=0;i<size[x];i++)
            printf("%2d\t",c[x][i]);
}
else
printf("\nProcess doesn't exist\n");
getch();
}









No comments:

Post a Comment