Your task This \"project\" is more like one of the accompanying homeworks. There
ID: 3672935 • Letter: Y
Question
Your task
This "project" is more like one of the accompanying homeworks. There are five problems. In the problems that ask you to change code, make the few changes necessary to fix the code without changing its overall approach.
Problem 2: Match each of the following statements with the explanation of what the statement does. (NOTE: One of the descriptions listed below actually matches two statements)
Statement Description 1. string * fp; a. sets a pointer variable to the last element of an array of five strings 2. string fish[ 5 ]; b. sets the string pointed to by a pointer variable to the value "salmon" 3. fp = &fish[ 4 ]; c. sets the fourth element of an array pointed to by the variable fp to the value "salmon" 4. *fp = "salmon"; d. moves the pointer fp back three strings in the array it points to 5. fp -= 3; e. initializes a boolean to true if the pointer variable fp points to the string at the start of the fish array, false otherwise 6. *(fp + 3) = "salmon"; f. declares a pointer variable to point to a variable of type string 7. fp[ 0 ] = "salmon"; g. declares a five element array of string 8. bool b = (fp == fish); h. initializes a boolean to true if fp points to a string whose value matches the string immediately following the string pointed to by fp,false otherwise 9. bool b = (*fp == *(fp + 1));
Explanation / Answer
I have completed the matching:
a)
fp = &fish[ 4 ];
b)
*fp = "salmon";
c)
*(fp + 3) = "salmon";
d)
fp -= 3;
e)
bool b = (fp == fish);
f)
string * fp;
g)
string fish[ 5 ];
h)
bool b = (*fp == *(fp + 1));
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.