- It declares variables
M
,initialTemp
,finalTemp
, andQ
to store values. - It takes input for
M
(mass),initialTemp
(initial temperature), andfinalTemp
(final temperature). - Using the formula for heat energy (
Q = M * (finalTemp - initialTemp) * 4184
), it calculates the amount of heat energy required to change the temperature of the substance. - Finally, it outputs the calculated heat energy (
Q
). - This program essentially computes the heat energy needed to change the temperature of a substance based on its mass and the temperature difference between the initial and final states.
- This program essentially computes the heat energy needed to change the temperature of a substance based on its mass and the temperature difference between the initial and final states.
C++ code:
#include <iostream>
using namespace std;
int main()
{
int M,initialtemp,finaltemp;
float Q;
cin>>M>>initialtemp>>finaltemp;
Q=(M*(finaltemp-initialtemp))*4184;
cout<<""<<Q;
return 0;
}
0 Comments
if you have any doubt, plz let me know