1.2 A First Look at Input/Output (4)

2013-10-07 16:13:41 · 作者: · 浏览: 97

EXERCISES SECTION 1.2

Exercise 1.3: Write a program to print Hello, World on the standard output.

Exercise 1.4: Our program used the addition operator, +, to add two numbers. Write a program that uses the multiplication operator, *, to print the product instead.

Exercise 1.5: We wrote the output in one large statement. Rewrite the program to use a separate statement to print each operand.

Exercise 1.6: Explain whether the following program fragment is legal.

  1. std::cout << "The sum of " << v1;   
  2. << " and " << v2;   
  3. << " is " << v1 + v2 << std::endl;  

If the program is legal, what does it do If the program is not legal, why not How would you fix it