All mock tests are FREE till 31 December — register to save your progress

Which of the following are legal C statements? (a) int *P = &44; (b) int *P = &r; (c) int P = &a; (d) int P = a;

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: C. (b) and (d)

Explanation

&44 takes the address of a constant (illegal), and int P = &a assigns a pointer to an int. int *P = &r and int P = a are legal (given variables r and a).

More Programming Languages and Computer Graphics questions