C + + learning experience

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.