AllInfoHub Logo

AllInfoHub – MCQ Practice

Arrays and Strings – Multiple Choice Questions (MCQs)

  1. 49. Can you have an array of pointers in C?

    • A. Yes
    • B. No
    • C. Only to functions
    • D. Only to characters
  2. 50. How do you declare an array of 5 integer pointers in C?

    • A. int *ptr[5];
    • B. int (*ptr)[5];
    • C. int **ptr[5];
    • D. pointer int ptr[5];
  3. 51. What is the use of an array of pointers to strings?

    • A. To store multiple strings efficiently
    • B. To manipulate individual characters within strings easily
    • C. To create dynamic arrays of characters
    • D. All of the above
  4. 52. What is the difference between a character array and a pointer to a character?

    • A. A character array allocates fixed memory
    • B. a pointer can point to dynamically allocated memory or a string literal
    • C. A pointer cannot point to a string
    • D. A character array cannot be passed to a function
  5. 53. What is dynamic memory allocation for arrays in C?

    • A. Allocating memory for an array at compile time
    • B. Allocating a fixed size array
    • C. Allocating memory for an array during program execution
    • D. Resizing an array after declaration
  6. 54. Which standard library function is used to allocate memory dynamically in C?

    • A. malloc()
    • B. calloc()
    • C. realloc()
    • D. free()
  7. 55. Which standard library function is used to deallocate dynamically allocated memory in C?

    • A. malloc()
    • B. calloc()
    • C. realloc()
    • D. free()
  8. 56. What is a potential issue with dynamic memory allocation for arrays if not handled properly?

    • A. Memory leaks
    • B. Stack overflow
    • C. Segmentation fault during compilation
    • D. Infinite loops
  9. 57. What is the purpose of the `calloc()` function in C?

    • A. To allocate a single block of memory
    • B. To allocate multiple blocks of memory and initialize them to zero
    • C. To reallocate memory
    • D. To free memory
  10. 58. What is the purpose of the `realloc()` function in C?

    • A. To allocate memory
    • B. To free memory
    • C. To change the size of a dynamically allocated memory block
    • D. To initialize memory to zero