+ 1

Can someone tell me if I'm right or wrong? C++

Complete each of the following statements by adding an asterisk, ampersand, or subscript wherever needed to make the statement do the job described by the comment. Use these declarations: double x =82.4, y; double num[4]={62.3, 65.5, 41.2, 73.0}; double *fp; a. fp = num[1]; /*make fp refer to element 1 of array num */ b. fp = x; /* copy value of x into referent of fp */ c. y = num; /* copy value of first element of array num into y. */ /* ANSWERS */ a.) *fp = num[1]; b.) fp = &x; c.) y= &num[1];

30th Apr 2017, 8:02 PM
Adiel Cowo
Adiel Cowo - avatar
1 Resposta
+ 2
not quite correct a. fp = num+1 what you're trying won't work you can't assign something to a dereferenced pointer b. I think it's correct c. y = num[0] or y = *num the first element of an array in c++ is at position 0 or you just write it without the position because an array is also a pointer to the first element in itself and to access the value you can dereference it
30th Apr 2017, 8:21 PM
‎ɐısıօլɐ
‎ɐısıօլɐ - avatar