Exercise Answer: 2.7
5.
#include <iostream>
using namespace Std;
void Fah ();
int main ()
{
Fah ();
return 0;
}
void Fah ()
{
int Celsius;
cout<< "Please enter a Celsius value:";
cin>>celsius;
Double Fahrenheit;
fahrenheit=1.8*celsius+32.0;
cout<<celsius<< "Degrees Celsius is" <<Fahrenheit<< "degrees Fahrenheit." <<endl;
int i;
cin>>i;
}
Cause of error: No statement written in header file//void Fah ();
Operation Result:
6. #include <iostream>
using namespace Std;
void Change ();
int main ()
{
Change ();
int i;
cin>>i;
return 0;
}
void Change ()
{
Double light;
cout<< "Please enter the number of light years:";
cin>>light;
Double ast;
Ast=63240*light;
cout<<light<< "Light Years" <<ast<< "astronomical units." <<endl;
}
Run results
7. #include <iostream>
using namespace Std;
void See (int hours,int minutes);//The arguments inside will determine the number of arguments to call in the main function
int main ()
{
cout<< "Enter The number of hours:";
int hours;
cin>>hours;
cout<< "Enter The number of minutes:";
int minutes;
cin>>minutes;
See (Hours,minutes);
int i;
cin>>i;
return 0;
}
void See (int hours,int minutes)
{
cout<< "Time:" <
}
C + + learning experience