← Back to Pointers
Question 454
Heap Array of Sensor Readings
Heap Array of Sensor Readings
The Reading struct is provided. Read an integer n, then n lines of "label value". Allocate an array of n Reading structs on the heap, fill it, and print: - one line per reading, formatted "<label>=<value>", in input order - a final line "Highest:<label>" naming the reading with the largest value If two readings tie for the largest value, report the one that came FIRST. For the input: 3 north 12 south 47 east 30 the output is exactly what is shown in Expected Output. Free the memory you allocate before the program ends — this question checks for memory leaks.
Expected Output:
north = 12 south = 47 east = 30 Highest: south
= newline. The output ends with a newline — print one after the last line.
Hints4 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 (p, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.