Top

Memory Allocation

31.

Can I increase the size of statically allocated array?

Answer: B

No answer description available for this question.

Enter details here

32.

Which of the following is an example for non linear data type?

Answer: A

A data structure is said to be linear if its elements form a sequence or a linear list. For example array, linked list, queue, stack etc. Elements in a non linear data structure do not form a sequence. For example Trees, graphs etc

Enter details here

33.

What will be the output of the program?

#include
#include

int main()
{
    union test
    {
        int i;
        float f;
        char c;
    };
    union test *t;
    t = (union test *)malloc(sizeof(union test));
    t->f = 10.10f;
    printf("%f", t->f);
    return 0;
}

 

Answer: C

No answer description available for this question.

Enter details here

34.

Assume integer is 2 bytes wide. How many bytes will be allocated for the following code?

#include
#include
#define MAXROW 3
#define MAXCOL 4

int main()
{
    int (*p)[MAXCOL];
    p = (int (*) [MAXCOL])malloc(MAXROW *sizeof(*p));
    return 0;
}

 

Answer: C

No answer description available for this question

Enter details here

Answer: C

Queue is a linear data structure which works on the principle of first in first out. This means that the first element to be inserted in a queue will be the first one to be removed.

Enter details here

36.

Memory allocation using malloc() is done in?

Answer: C

None

Enter details here

37.

What is the output of this C code?

void main()
{
char *p = calloc(100, 1);
p = "welcome";
printf("%s\n", p);
}

 

Answer: D

None

Enter details here

38.

malloc() allocates memory from the heap and not from the stack.

Answer: A

Heap area consist of hash codes .i.e. addreses while stack may or may not be that's why malloc() allocates memory from the heap

Enter details here

39.

calloc initialises memory with all bits set to zero.

Answer: A

None

Enter details here

40.

The size of both stack and heap remains the same during run time.

Answer: B

Memory can be allocated or de-allocated during the run time in the heap region. Memory bindings (allocation and de-allocation) are established and destroyed during the execution of the program. Hence we can see that the size of heap does not remain same during run time. However, the size of stack remains the same.

Enter details here

Loading…
Tags: Memory Allocation Questions and Answers || Memory Allocation MCQ Questions and Answers || Memory Allocation GK Questions and Answers || Memory Allocation GK MCQ Questions || Memory Allocation Multiple Choice Questions and Answers || Memory Allocation GK || GK on Memory Allocation || C Programming Questions and Answers || C Programming MCQ Questions and Answers || C Programming GK Questions and Answers || GK on C Programming