Top

Memory Allocation

81.

Assume integer is 2 bytes wide. What will be the output of the following code?

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

int main()
{
    int (*p)[MAXCOL];
    p = (int (*) [MAXCOL])malloc(MAXROW *sizeof(*p));
    printf("%d, %d\n", sizeof(p), sizeof(*p));
    return 0;
}

 

Answer: A

No answer description available for this question

Enter details here

82.

What is the output of this program?

#include 
#include  
int main()
{
  int *p;
  p = (int *)malloc(40);
  printf("%d", sizeof(p));
  free(p);
  return 0;
}

 

Answer: C

Since p is the pointer variable of integer type, thus the size of integer type is 4.

Enter details here

83.

Can we increase the size of statically allocated array?

Answer: B

Yes we increase the size of statically allocated array

Enter details here

84.

What function should be used to free the memory allocated by calloc() ?

Answer: C

No answer description available for this question

Enter details here

85.

Point out the error in the following program.

#include
#include

int main()
{
    char *ptr;
    *ptr = (char)malloc(30);
    strcpy(ptr, "RAM");
    printf("%s", ptr);
    free(ptr);
    return 0;
}

 

Answer: B

ptr = (char*)malloc(30);

Enter details here

86.

Specify the 2 library functions to dynamically allocate memory?

Answer: C

No answer description available for this question

Enter details here

87.

Array is preferred over linked list for the implementation of ________

Answer: C

When we try to implement binary search using linked list, the traversal steps per element increases in order to find the middle element. Thus, this process is slow and inefficient. This process is much faster using an array, hence it is preferable to use an array for the implementation of binary search.

Enter details here

88.

Which of the following statement is correct prototype of the malloc() function in c ?

Answer: D

 

By defalut for malloc() function return type is void.

Enter details here

89.

The type of linked list in which the node does not contain any pointer or reference to the previous node:

Answer: B

A singly linked list is one in which each node has two fields, namely data field and pointer field. Data field stores the data and the pointer field points to the address of the next node.

Enter details here

90.

malloc() returns a NULL if it fails to allocate the requested memory.

Answer: A

No Explanation

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