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.

  1. A.

    Static and static

  2. B.

    Static and stack

  3. C.

    Static and heap

  4. 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.

Explore the full course: Dsssb Tgt Computer Science Paper 2