hey i have been given the following assignment, but i cant understand it. Can anybody elaborate it. Thanks.
A cup of water (250 ml) is heated from 0 to 100 C. Find the change in internal energy (Required heat to boil) for the cup of water, and keep printing it for temperatures in range 5 - 100 C. Change temperature using function call by reference. Make functions for calculating mass() and req_heat() as well. Density = 1, w_cp = 4.2.
Formulas
*mass = density * volume
req_heat = w_cp * mass * (max_temp - altered_temp)
use const for universal constants.
The code looks ok by just scanning it over. Did it compile? If so, put in some dummy numbers and calculate it by hand. If your hand calculation is the same as the output, you know it works. If it didn't compile, look at the output and fix the stated errors. Then recompile and test again.
When I compiled, in line 35 (function 'void req_heat(int&, int&)':
[Warning] converting to int from double.
I changed int &alttemp to a double value. It works now.