+3 votes
in Class 12 by kratos

Given the following definitions:

int ival = 2048;

int *iptr;

double *dptr;

which of the following assignment, if any, are ***? Explain why.

(a) ival=*iptr

(b) *iptr=ival;

(c) *iptr=&ival

(d) dptr=iptr;

(e) ival=iptr;

(f) iptr=ival;'

(g) iptr=&ival;

(h) dptr=*iptr;

1 Answer

+5 votes
by kratos
 
Best answer

(a) legal assignment.

(b) legal assignment.

(c) *** assignment, cannot assign a address of normal variable to pointer variable.

(d) *** assignment, cannot assign a integer pointer to a double pointer.

(e) *** assignment, cannot assign pointer variable to a normal variable.

(f) *** assignment, cannot assign normal variable to a pointer variable.

(g) legal assignment.

(h) *** assignment, cannot assign a integer pointer to a double pointer.

...