This is a question for a test I have coming up tonight:
The only way that I have been able that this wuold work was if I had Maximum() return a pointer and then dereference it to assign 17.1 to it. But I can't do that. Obviously I can't just return a double, I have to return a double pointer, but when I return the pointer to the highest value it fails to compile with the error, 'not an lvalue.' Is this possible?
Problem 4. Suppose x is an array of n double values declared by the following statements.
double x[100];
int n;
Write the definition of the function Maximum() that will put the component with the maximum
value to 17.1 with the call
Maximum(x, n) = 17.1;
You may assume 0 < n < 101. In the case of ties for the maximum value, the component with
the smallest subscript should be changed.
The only way that I have been able that this wuold work was if I had Maximum() return a pointer and then dereference it to assign 17.1 to it. But I can't do that. Obviously I can't just return a double, I have to return a double pointer, but when I return the pointer to the highest value it fails to compile with the error, 'not an lvalue.' Is this possible?