Multiple choice

What are the types of variable f2 and p2 in the following declaration?

#define floatptr float * #define int * intptr

floatptr f1,f2; intptr p1,p2;

  1. float, int pointer

  2. float pointer, int pointer

  3. float, int

  4. float pointer, int

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The macro floatptr expands to float , so floatptr f1,f2 becomes float *f1,f2. Due to precedence, this declares f1 as float but f2 as float (only f1 gets the asterisk). For intptr (defined as int ), intptr p1,p2 becomes int *p1,p2, declaring p1 as int and p2 as int. Therefore f2 is float and p2 is int.