Question
For each of the following parts, write a single C++ statement that performs the indicated task. For each part, assume that all previous statements have
For each of the following parts, write a single C++ statement that performs the indicated task. For each part, assume that all previous statements have been executed (e.g., when doing part e, assume the statements you wrote for parts a through d have been executed).
a.) Declare a pointer variable named fp that can point to a variable of type string.
b.) Declare fish to be a 5-element array of strings.
c.) Make the fp variable point to the last element of fish.
d.) Make the string pointed to by fp equal to "salmon", using the * operator.
e.) Without using the fp pointer, and without using square brackets, set the element at index 3 of the fish array to have the value "yellowtail".
f.) Move the fp pointer back by three strings.
g.) Using square brackets, but without using the name fish, set the element at index 2 of the fish array to have the value "eel".
h.) Without using the * operator, but using square backets, set the string pointed to by fp to have the value "tuna".
i.) Declare a bool variable named d and initialize it with an expression that evaluates to true if fp points to the string at the start of the fish array, and false otherwise.
j.) Using the * operator in the initialization expression, declare a bool variable named b and initialize it to true if the string pointed to by fp is equal to the string immediately following the string pointed to by fp, and false otherwise.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started