Which of the following are legal statements in C programming language?
(a) int *P = &44;
(b) int *P = &r;
(c) int P = &a;
(d) int P = a;
Statement (a) is not legal because we cannot take the address of a constant value like $44$.
Statement (b) is legal because if $r$ is an integer variable, then &r gives its address and it can be stored in an integer pointer.
Statement (c) is not legal because &a gives address, but $P$ is declared as normal integer, not pointer.
Statement (d) is legal because if $a$ is an integer variable, then its value can be assigned to integer variable $P$.
So, legal statements are:
(b) and (d)
Online Test Series, Information About Examination,
Syllabus, Notification
and More.
Online Test Series, Information About Examination,
Syllabus, Notification
and More.