← Back to Pointers
Question 690
Rainfall Average from a Heap Double Array
Rainfall Average from a Heap Double Array
Allocate a heap array of DAYS (4) doubles and store it in the pointer rainfall. The four readings (2.5, 3.5, 1.0 and 4.0) are assigned for you on the lines right after the allocation. Add every reading to total inside the loop that is already written; the cout line already divides total by DAYS with fixed and setprecision(2).
Print exactly what is shown in Expected Output.
Free the memory you allocate before the program ends — this question checks for memory leaks.Expected Output:
Average rainfall: 2.75= newline. The output ends with a newline — print one after the last line.
Hints3 available
Sign in to use hintsTopics:
Pointers
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.