C++primer Chapter Two programming exercises answer

Source: Internet
Author: User

2.7.1

#include <iostream>intMain () {using namespacestd; Charname[ -]; Charaddress[ -]; cout<<"Input Name:"; CIN>>name; cout<<"Input Address:"; CIN>>address; Cin.Get(); cout<<"name is"<<name; cout<<Endl; cout<<"Address is"<<address; Cin.Get();}

2.7.2

#include <iostream>intMain () {using namespacestd; intdistance; cout<<"Input Distance:"; CIN>>distance; Cin.Get(); cout<<"long_distance is"; cout<< Distance * -; Cin.Get();}

2.7.3

#include <iostream>using namespacestd;voidfunc_1 ();voidfunc_2 ();intMain () {//cin.get ();func_1 ();    Func_1 ();    Func_2 ();    Func_2 (); Cin.Get();}voidfunc_1 () {cout<<"Three Blind Mice"<<Endl;}voidfunc_2 () {cout<<"See how they run"<<Endl;}

2.7.4

#include <iostream>int  main () {    usingnamespace  std;     int Age ;     " Enter your Age: " ;     >> age ;    Cin. Get ();      A ;    Cin. Get ();}

2.7.5

#include <iostream>DoubleConvertDouble);intMain () {using namespacestd; Doubledegrees; cout<<"Please enter a Celsius value:"; CIN>>degrees; Cin.Get(); cout<< degrees <<"Celsius is"<< CONVERT (degrees) <<"degrees Fahrenheit"; Cin.Get();}DoubleConvertDoubledegrees) {    DoubleFahrenheit = degrees*1.8+32.0; returnFahrenheit;}

2.7.6

#include <iostream>DoubleConvertDouble);intMain () {using namespacestd; DoubleLight_years; cout<<"Enter the number of light years:"; CIN>>Light_years; Cin.Get(); cout<< Light_years <<"Light years ="<< convert (light_years) <<"Astronomical Units"; Cin.Get();}DoubleConvertDoublelight_years) {    DoubleUnits = Light_years *63240; returnunits;}

2.7.7

#include <iostream>voidTimerint,int);intMain () {using namespacestd; inthours, minutes; cout<<"Enter the number of hours:"; CIN>>hours; cout<<"Enter the number of minutes:"; CIN>>minutes; Cin.Get();    Timer (hours, minutes); Cin.Get();}voidTimerintHoursintminutes) {Std::cout<<"Timer:"<< hours <<":"<<minutes;}

C++primer Chapter Two programming exercises answer

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.