-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path2a_Sequential.c
56 lines (49 loc) · 1.26 KB
/
2a_Sequential.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include<stdlib.h>
#include<stdio.h>
int main()
{
int start,length,*f,i,j;
char ch;
for(i=0;i<50;i++)
f[i] = 0;
do
{
printf("Enter the starting block :\n");
scanf("%d",&start);
printf("Enter the length : \n");
scanf("%d",&length);
for(i= start;i<(start+length);i++)
{
if(f[i] == 0)
{
f[i] = 1;
printf("%d -> %d\n",i,f[i]);
}
else
{
printf("File has already allocated\n");
}
}
printf("\nFile has been allocated (do you want to allocate once more (y/n) \n");
scanf(" %c",&ch);
}while(ch == 'Y' || ch == 'y');
}
/*
OUTPUT:
aromal@Aromal-Nitro-5:~/labdemo$ ./a.out
Enter the starting block :
4
Enter the length :
10
4 -> 1
5 -> 1
6 -> 1
7 -> 1
8 -> 1
9 -> 1
10 -> 1
11 -> 1
12 -> 1
13 -> 1
File has been allocated (do you want to allocate once more (y/n)
*/