AllInfoHub Logo

AllInfoHub – MCQ Practice

Pointers – Multiple Choice Questions (MCQs)

  1. 13. What is the relationship between arrays and pointers in C?

    • A. An array name can be used as a constant pointer to the first element of the array
    • B. Pointers cannot point to arrays
    • C. Arrays are a different data type and have no relation to pointers
    • D. Only character arrays can be accessed using pointers
  2. 14. How do you access the value of the first element of an array 'arr' using a pointer 'ptr' that points to 'arr'?

    • A. *arr
    • B. ptr[0]
    • C. *ptr
    • D. arr[0]
  3. 15. What is a pointer to a pointer in C?

    • A. A pointer that stores the address of another pointer
    • B. A pointer that points to an array of pointers
    • C. A pointer to a function
    • D. A pointer to a structure
  4. 16. How do you declare a pointer to an integer pointer in C?

    • A. int *ptr;
    • B. int **ptr;
    • C. int ***ptr;
    • D. pointer *int ptr;
  5. 17. What is the use of a pointer to a pointer?

    • A. To pass multi-dimensional arrays to functions
    • B. To dynamically allocate multi-dimensional arrays
    • C. To indirectly modify the value of a pointer
    • D. All of the above
  6. 18. What is a function pointer in C?

    • A. A pointer that stores the return value of a function
    • B. A pointer that stores the address of a function
    • C. A pointer to the parameters of a function
    • D. A pointer to a local variable inside a function
  7. 19. How do you declare a function pointer that points to a function taking an integer and returning an integer?

    • A. int *func_ptr(int);
    • B. int (*func_ptr)(int);
    • C. pointer int func_ptr(int);
    • D. func_ptr int(int);
  8. 20. What is the use of function pointers?

    • A. To pass functions as arguments to other functions
    • B. To store the result of a function call
    • C. To declare functions dynamically
    • D. To access global variables
  9. 21. What is a void pointer in C?

    • A. A pointer that cannot store any address
    • B. A pointer that can store the address of any data type
    • C. A pointer that always points to NULL
    • D. A pointer to a function with no return value
  10. 22. How do you declare a void pointer in C?

    • A. void ptr;
    • B. *void ptr;
    • C. void *ptr;
    • D. ptr void;
  11. 23. Why is it necessary to cast a void pointer before dereferencing it?

    • A. Because the compiler needs to know the data type being pointed to
    • B. Void pointers cannot be dereferenced
    • C. Casting is only required for function pointers
    • D. It is not necessary to cast void pointers
  12. 24. What is a dangling pointer in C?

    • A. A pointer that points to a valid memory location
    • B. A pointer that has not been initialized
    • C. A pointer that points to a memory location that has been freed
    • D. A pointer that points to NULL