"C + + Primer plus English version Sixth edition" Chapter 2

Source: Internet
Author: User

"C + + Primer Plus English version of the sixth edition," said. It is recommended to buy this one, this is the upper and lower fascicle. Moreover, the publication time is the latest 2015, buy back found online errata basically have been corrected, the very individual error did not affect the understanding, good ah! And found that the wording is particularly simple, reading is also smooth.
Electronic version (PDF):
C + + Primer Plus Sixth edition.pdf密码:910h
C + + primer.plus 6th edition Chinese version密码:ihsq
Appendix J of the solution reference Book of the chpter Review
Programming Exercises mainly refer to the following posts:
C++-primer-plus (6th edition) Chinese version of the programming exercise answer (full version). pdf密码:20rn
C++-primer-plus (sixth edition) programming exercise solution (incomplete version). doc密码:hxzs
Charlesdong
The code in section programming exercises Below is personally knocked out and can be run. Environment: MacOS Down

Chapter Review
  1. They is called functions.
  2. It causes the contents of the file to being substituted for this iostream directive before final compilation.
  3. It makes definitions made in the std namespace available to a program.
  4. cout << "Hello, world" << endl;Orcout << "Hello, world\n";
  5. int cheeses;
  6. cheeses = 32;
  7. cin >> cheeses;
  8. cout << "We have " << cheeses << " varieties of cheese\n";
  9. The function froop() expects to is called with one argument, which'll be double is type, and that the function would return a T Ype int value. For instance, it could is used as follows:
    int gval = froop(3.14159);
    The function has a rattle() no return value and expects an int argument. For instance, it could is used as follows:
    rattle(37);
    The function returns an and expects to is prune() int used without an argument. For instance, it could is used as follows:
    int residue = prune();
  10. You do not have the-use return -a function when the function has the return type void . However, you can use it if you don ' t give a return value:
    return;
  11. The likely cause it, the function loses a statement to using namespace std; declare a directive of output.
    Place using namespace std; above the main() function;
    Place in the using std::cout; main() function;
    Type as following:using std::cout << "Please enter your PIN: " << std::endl;
Programming Exercises1
#include <iostream>int main(){    usingnamespace std;        "Name: NaRiSu;\n"         "Address: BeiJing;" << endl;             return0;}
2
#include <iostream>int main(){    usingnamespace std;        int furlong;    cin >> furlong;    " furlong(s) = "         220" yard(s)" << endl;        return0;}
3
#include <iostream>void f1();void f2();usingnamespace std;int main(){       f1();    f1();    f2();    f2();        return0;}void f1(){    "Three blind mice" << endl;}void f2(){    "See how they run\n"// 也可以用f1()函数中的endl形式。        return// void f2()表明无返回值,故可以这样写;也可以如f1()不写return语句。}
4
#include <iostream>int main(){    usingnamespace std;        "Enter your age: ";    int age;    cin >> age;    "Your age in months is "12"." << endl;        return0;}
5
#include <iostream>double fahrenheit(double);int main(){    usingnamespace std;        "Please enter a Celsius value: ";    int celsius;    cin >> celsius;    " degrees Celsius is "         " degrees Fahrenheit." << endl;        return0;}double fahrenheit(double n){    return1.832.0;}
6
#include <iostream>double astronomical(double);int main(){    usingnamespace std;        "Enter the number of light years: ";    double light;    cin >> light;    " light years = "         " astronomical units." << endl;        return0;}double astronomical(double n){    return63240 * n;}
7
 #include <iostream>  void  F (int , int );        int  Main () {using  namespace  std;    cout <<  "Enter the number of Hours:" ;    int  hour;    CIN >> Hour;    cout <<  "Enter the number of minutes:" ;    int  minute;    CIN >> minute;        F (hour, minute); return  0 ;} void  F (int  H, int  m) {        Using  namespace  std; cout <<  "time:"  << H <<  << m << Endl; }

C + + Primer plus the sixth edition of the English version Chapter 2

Related Article

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.