Home » NO IDEA » contiguous file allocation

contiguous file allocation

Blog Stats

  • 14,863 hits
April 2013
M T W T F S S
« Mar   Oct »
1234567
891011121314
15161718192021
22232425262728
2930  

#include<stdio.h>
int start;
int main()

{
int i,n,block[20];
printf("Enter the no. of file:\n");
scanf("%d",&n);
printf("Enter the number of blocks needed for each file:\n");
for(i=0;i<n;i++)
scanf("%d",&block[i]);
start=0;
printf("\t\tFile name\tStart\tSize of file\t\t\n");
printf("\n\t\tFile1\t\t%d\t\t\t%d\n",start,block[0]);
for(i=2;i<=n;i++)
{

start=start+block[i-2];
printf("\t\tFile%d\t\t%d\t\t%d\n",i,start,block[i-1]);
}

return 0;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: