Question

Exercise P7.6. Write a function that returns a pointer to the maximum value of an array of floating-point data: double* maximum(double al], int a size) If a size is 0, return NULL.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:

code:

double* maximum(double a[] , int a_size)

{

double max = a[0];

for(int i= 0; i<a_size; i++)

{

if(max< a[i])

max = a[i]

}

retun max;

}

I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)

Add a comment
Know the answer?
Add Answer to:
Exercise P7.6. Write a function that returns a pointer to the maximum value of an array...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • c++ questions Write a function that returns a pointer to the maximum value of an array...

    c++ questions Write a function that returns a pointer to the maximum value of an array of ints: int* ptrToMaximum(int* array, int* end); You don’t have to worry about what happens if end points beyond end(array). Maybe it is nice to allow end to point to before end(array). In the case that (array == end), you should return nullptr. Running the following main function should result in 8 7 being printed to the console. int main() { int a[] =...

  • write the program in c++ Pointen & A???ys: Write u function that is passed a pointer...

    write the program in c++ Pointen & A???ys: Write u function that is passed a pointer to a float array, and the size the array as an int. The function should return a pointer to the maximum element in the array The function should be: int *maxp(float* ap, int size) Write a main() program to lest the function with different input arrays. Grading Criteria (1 point each): Uses cin/cout correct function definition prompts user for input, reads it in correct...

  • The exists function returns whether a given value exists in the given array or not. It...

    The exists function returns whether a given value exists in the given array or not. It returns 1 (true) if the value exists in the given array, and returns 0 (false) otherwise. The first function parameter is the value searched; the second parameter is the array, the third one is the array size. Fill in the blanks by dragging and dropping the items below into the code in their suitable places. Notice that some of the items are distractors and...

  • please use c ++ language and write the comment too. thanks Pointer Arithmetic Write a function...

    please use c ++ language and write the comment too. thanks Pointer Arithmetic Write a function that passes an array address to a function as a pointer. Using pointer arithmetic, the function determines the average, high, and low value of the array. Your function should have this header: void pointerArithmetic(int *array, int size, double &average, int &high, int &low) Parameter size is the number of elements in array. You may not use the subscript notation [] inside your function –...

  • C++ Programme Write a function that receives, as arguments, a pointer to a double array, as...

    C++ Programme Write a function that receives, as arguments, a pointer to a double array, as well as the number of elements: in the array(int). The function must use pointer operations and calculate the standard deviation of the elements in the array. The function returns the standard deviation to the calling statementſ Use the function in main( to display its operation. | Example: array = (11.2, 2.4, 3.13, 16.4, 5.8, 9.22, 4.9, 10.5, 6.5, 2.99) std Dev(array) = 4.249367 ZWI...

  • -Create a function output() in C that takes the pointer to the array and its size...

    -Create a function output() in C that takes the pointer to the array and its size and prints the arrays' contests. (malloc format) (function prototype : void output(int *arrayPtr, int size); -Create a function check() in C that takes the pointer to the array and a number and checks if the number is in the array. If the number is in the array, returns the index of the element of the array holding the number. Otherwise, returns -1.

  • A function that takes three parameters: an int array, an int n that is the size...

    A function that takes three parameters: an int array, an int n that is the size of the array and an int pointer max that is to assign the maximum value in the array. The function will find and return the index of the first occurrence of the maximum value in the array and assign the maximum value to the pointer. For example, in the array {1, 2, 6, 5, 6, 4, 3, 6, 4}, the maximum value is 6...

  • Write a function that takes an array of integers as an argument and returns a value...

    Write a function that takes an array of integers as an argument and returns a value based on the sums of the even and odd numbers in the array. Let X = the sum of the odd numbers in the array and let Y = the sum of the even numbers. The function should return X – Y The signature of the function is: int f(int[ ] a) Examples if input array is return {1} 1 {1, 2} -1 {1,...

  • Write a value-returning C++ function returns the average length of an array of strings. Name the...

    Write a value-returning C++ function returns the average length of an array of strings. Name the function stringsAverageLength and use the following header: double stringsAverageLength(string array [], int n) { } where the parameter 'array' has 'n' strings and the return value is the average length of all of the strings in the array. For example, if the function is called like this: string cars[3] = { "Toyota", "Ford", "Tesla" }; cout << fixed << setprecision(2) << stringsAverageLength(cars, 3) <<...

  • average Function Write a function that finds an average of the array using only pointers (and...

    average Function Write a function that finds an average of the array using only pointers (and pointer arithmetic) to move through the array. Test the function in a driver program. Function header: double average(int* array, int size)

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT