LearnFrenzy
Sign in Take a free test

Pointers · Pointer Basics MCQ · Question 4

int *p, q; – what type is q? Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 4 Back to Exercise

After the declaration int *p, q; what are p and q?

  • A both are pointers to int
  • B p is a pointer to int, q is an int Correct
  • C p is an int, q is a pointer to int
  • D it is a compile error
Correct Answer: Option B

The * belongs to the name next to it, not to the type. To declare two pointers write int *p, *q;. This is why many style guides declare one pointer per line.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Popular