Chapter 2 Exercise Set 1

  1. In the Outputting variables section, the body of the main function is given to you without the other lines needed for the program to compile and run. Include these lines of code in a complete program in a file named outputing_variables.cpp, then compile and run it and verify the result. Don’t forget to add the return statement at the end of the main function.

  2. Write a program in a file named ten_mathematical_expressions.cpp that displays ten mathematical expressions along with their evaluations in a form like:

    int n = 5;
    int m = 7;
    cout << "The product of " << n << " and " << m << " is ";
    cout << n * m << "." << endl;
    

    which when compiled and run will display:

    The product of 5 and 7 is 35.