program for LINKED algoritham using c-languge


LINKED ALGORITHM
#include<stdio.h>
#include<conio.h>
typedef struct file
{
 char name[10];
 int start,size,block[10];
}fil;


main()
{
 fil f[10];
int i,j,n;
clrscr();
printf("Enter number of files: ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
 printf("\nEnter the filename: ");
scanf("%s",f[i].name);
printf("Enter the starting block of the file: ");
scanf("%d",&f[i].start);
f[i].block[0]=f[i].start;
printf("Enter the size of the file: ");
scanf("%d",&f[i].size);
for(j=1;j<f[i].size;j++)
{
 printf("Enter the next block number:");
 scanf("%d",&f[i].block[j]);
}
}
printf("File \t Start \t Size \t Blocks \n");
for(i=0;i<n;i++)
{
 printf("%s\t%d\t%d\t",f[i].name,f[i].start,f[i].size);
 for(j=0;j<f[i].size;j++)
 printf("%d-->",f[i].block[j]);
printf("-1 \n");
}
printf("\n");                               
getch();
}





No comments:

Post a Comment