← Back to Pointers
Question 682
Calibrate a SensorReading Struct Through a Pointer
Calibrate a SensorReading Struct Through a Pointer
A SensorReading struct is already declared with two int fields, id and celsius. Fill in voidapplyCalibration(SensorReading *r, int offset)so it adds offset to the reading's celsius field. main is already written: it creates a reading with id 7 and celsius 20, callsapplyCalibration(&reading, 5), then prints the reading. The program must print exactly the output shown in Expected Output. Do not print anything inside applyCalibration, and leave the id field alone.
Expected Output:
id=7 celsius=25= newline. The output ends with a newline — print one after the last line.
Hints2 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.