Consider the given below code: include<stdio.h> define LIM void fun(int);
Consider the given below C code:
# include<stdio.h>
# define LIM 10
void fun(int);
int array[LIM]; // array_1
void main()
{
int size;
printf("size");
scanf("%d",&size);
fun(size);
}
void fun(int ss)
{
int arr[ss]; // array_2
int i;
for(i=0;i<ss;i++)
arr[i]=i+2;
for(i=0;i<ss;i++)
printf("%d\t",arr[i]);
}
The array_1 and array_2 will get stored in ___________ memory and ___________ memory, respectively.
- A.
Static and static
- B.
Static and stack
- C.
Static and heap
- D.
Heap and stack
Attempted by 2 students.
Show answer & explanation
Correct answer: B
the global array will get stored in static memory, while the array in function “fun” will get stored in stack memory.