-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfcfs.c
More file actions
30 lines (27 loc) · 688 Bytes
/
Copy pathfcfs.c
File metadata and controls
30 lines (27 loc) · 688 Bytes
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
#include<stdio.h>
#include<stdlib.h>
int main()
{
int arr[100],seek_count=0,distance, cur_track,n,head,i;
printf("Enter the number of Requests\n");
scanf("%d",&n);
printf("Enter the Requests sequence\n");
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
printf("Enter initial head position\n");
scanf("%d",&head);
for(i=0;i<n;i++)
{
cur_track = arr[i];
distance = abs(cur_track - head);
seek_count += distance;
head = cur_track;
}
printf("\n Total number of seek operations = %d",seek_count);
printf("\n Seek Sequence is");
for (int i = 0; i < n; i++)
{
printf("%d\n",arr[i]);
}
return 0;
}