Quiz: Pointers

To View Tricks: Login Required

Number of Questions: 10

Question: 1 -

A pointer can be initialized with

Options:
  1. All of the above

  2. Zero

  3. Address of an object of same type

  4. Null

  5. Answer:

    All of the above

    Solution:

    A pointer can be initialized with null, zero and Address of an object of same type.


Question: 2 -

Which of the following is the correct way to declare a pointer ?

Options:
  1. int &ptr

  2. int ptr

  3. int *ptr

  4. All of the above

  5. Answer:

    int *ptr

    Solution:

    int *ptr is the correct way to declare a pointer.


Question: 3 -

Choose the right option string* x, y;

Options:
  1. none of the above

  2. y is a pointer to a string, x is a string

  3. x is a pointer to a string, y is a string

  4. Both x and y are pointers to string types

  5. Answer:

    x is a pointer to a string, y is a string

    Solution:

    * is to be grouped with the variables, not the data types


Question: 4 -

Which of the following gives the [value] stored at the address pointed to by the pointer : ptr?

Options:
  1. ptr

  2. *ptr

  3. Value(ptr)

  4. &ptr

  5. Answer:

    *ptr

    Solution:

    *ptr gives the [value] stored at the address pointed to by the pointer : ptr.


Question: 5 -

Generic pointers can be declared with__________ .

Options:
  1. None of the above

  2. auto

  3. void

  4. asm

  5. Answer:

    void

    Solution:

    Generic pointers can be declared with void.