Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
nmims post
Objective Type Set
Online MCQ Assignment
Question Solution
Solved Question
Uncategorized

1. Which of the following will return a result most quickly for searching a given key?
a) Unsorted Array
b) Sorted Array
c) Sorted linked list
d) Binary Search Tree

View Answer

Answer: d [Reason:] None.

2. On freeing a dynamic memory, if the pointer value is not modified, then the pointer points to.
a) NULL
b) Other dynamically allocated memory
c) The same deallocated memory location
d) It points back to location it was initialized with

View Answer

Answer: c [Reason:] None.

3. For the following program, Which of the following should be used for freeing the memory allocated?

  1.     #include <stdio.h>
  2.     struct p
  3.     {
  4.         struct p *next;
  5.         int x;
  6.     };
  7.     int main()
  8.     {
  9.         struct p *p1 = (struct p*)malloc(sizeof(struct p));
  10.         p1->x = 1;
  11.         p1->next = (struct p*)malloc(sizeof(struct p));
  12.         return 0;
  13.     }

a) free(p1);
    free(p1->next)
b) free(p1->next);
    free(p1);
c) free(p1);
d) all of the mentioned

View Answer

Answer: b [Reason:] None.

4. What is the output of this C code?

  1.     #include <stdio.h>
  2.     struct p
  3.     {
  4.         struct p *next;
  5.         int x;
  6.     };
  7.     int main()
  8.     {
  9.         struct p *p1 = calloc(1, sizeof(struct p));
  10.         p1->x = 1;
  11.         p1->next = calloc(1, sizeof(struct p));
  12.         printf("%dn", p1->next->x);
  13.         return 0;
  14.     }

a) Compile time error
b) 1
c) Somegarbage value
d) 0

View Answer

Answer: d [Reason:] None.

5. What is the output of this C code?

  1.     #include <stdio.h>
  2.     struct p
  3.     {
  4.         struct p *next;
  5.         int x;
  6.     };
  7.     int main()
  8.     {
  9.         struct p* p1 = malloc(sizeof(struct p));
  10.         p1->x = 1;
  11.         p1->next = malloc(sizeof(struct p));
  12.         printf("%dn", p1->next->x);
  13.         return 0;
  14.     }

a) Compile time error
b) 1
c) Somegarbage value
d) 0

View Answer

Answer: c [Reason:] None.

6. calloc initialises memory with all bits set to zero.
a) True
b) False
c) Depends on the compiler
d) Depends on the standard

View Answer

Answer: a [Reason:] None.

7. realloc(ptr, size), where size is zero means
a) Allocate a memory location with zero length
b) Free the memory pointed to by ptr
c) Undefined behaviour
d) Doesn’t do any reallocation of ptr i.e. no operation

View Answer

Answer: b [Reason:] None.

.woocommerce-message { background-color: #98C391 !important; }