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