1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
#include <iostream>
#include <cstdlib>
#include <math.h>
using namespace std;
void input(double &, double &, double &, double &);
double Q (double, double,double,double);
void display (double);
int main(int arg, char *argv[])
{
double m, c, t1, t2, temperature, heat;
input (m, c, t1, t2);
heat= Q(m, c, t1, t2);
display (heat);
return 0;
}
void input(double &m, double &c, double &t1, double &t2)
{
cout<<"mass: "<<endl;
cin>>m;
cout<<"specific heat: "<<endl;
cin>>c;
cout<<"initial temp.: "<<endl;
cin>>t1;
cout<<"final temp.: "<<endl;
cin>>t2;
}
double Q (double m, double c, double t1, double t2)
{
double heat;
heat= m*c*(t2-t1);
return heat;
}
void display (double heat)
{
cout<<"heat energy is= "<<heat<<endl;
}
|