AllInfoHub Logo

AllInfoHub – MCQ Practice

Pointers – Multiple Choice Questions (MCQs)

  1. 49. How do you declare a constant pointer to an integer in C?

    • A. const int *ptr;
    • B. int const *ptr;
    • C. int * const ptr;
    • D. All of the above
  2. 50. What is a constant pointer to a constant integer in C?

    • A. A pointer whose address cannot be changed and the value it points to cannot be changed
    • B. A pointer that always points to NULL
    • C. A pointer that cannot be dereferenced
    • D. A pointer to a read-only memory location
  3. 51. How do you declare a constant pointer to a constant integer in C?

    • A. const int *ptr;
    • B. int const *ptr;
    • C. const int * const ptr;
    • D. int * const ptr;
  4. 52. What is the purpose of using pointers with structures in C?

    • A. To access structure members more efficiently
    • B. To pass structures to functions by reference
    • C. To create linked data structures
    • D. All of the above
  5. 53. Which operator is used to access members of a structure through a pointer in C?

    • A. .
    • B. &
    • C. *
    • D. ->
  6. 54. If `struct Point { int x, y; }; struct Point p = {10, 20}; struct Point *ptr = &p;`, how do you access the 'x' member using the pointer?

    • A. ptr.x
    • B. (*ptr).x
    • C. ptr->x
    • D. ptr[0].x
  7. 55. What is the output of the following code? `struct Data { int val; }; struct Data d = {5}; struct Data *ptr = &d; ptr->val = 12; printf(\%d\"",d.val);`"""

    • A. 5
    • B. 12
    • C. The address of d
    • D. Error