-
Notifications
You must be signed in to change notification settings - Fork 1
/
7a.c
36 lines (34 loc) · 928 Bytes
/
7a.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
#include <stdio.h>
int main(int argc, char const *argv[])
{
int ms, mp[10], i, temp, n = 0;
char ch = 'y';
printf("\nEnter the total memory available (in Bytes)-- ");
scanf("%d", &ms);
temp = ms;
for (i = 0; ch == 'y'; i++, n++)
{
printf("\nEnter memory required for process %d (in Bytes) -- ", i + 1);
scanf("%d", &mp[i]);
if (mp[i] <= temp)
{
printf("\nMemory is allocated for Process %d ", i + 1);
temp = temp - mp[i];
}
else
{
printf("\nMemory is Full");
break;
}
printf("\nDo you want to continue(y/n) -- ");
scanf(" %c", &ch);
}
printf("\n\nTotal Memory Available -- %d", ms);
printf("\n\n\tPROCESS\t\t MEMORY ALLOCATED ");
for (i = 0; i < n; i++)
printf("\n \t%d\t\t%d", i + 1, mp[i]);
printf("\n\nTotal Memory Allocated is %d", ms - temp);
printf("\nTotal External Fragmentation is %d", temp);
printf("\n");
return 0;
}