2.2 Variables (9)

2013-10-07 16:15:44 · 作者: · 浏览: 87

EXERCISES SECTION 2.2.4

Exercise 2.13: What is the value of j in the following program

  1. int i = 42;   
  2. int main()   
  3. {   
  4. int i = 100;   
  5. int j = i;   
  6. }  

Exercise 2.14: Is the following program legal If so, what values are printed

  1. int i = 100, sum = 0;   
  2. for (int i = 0; i != 10; ++i)   
  3. sum += i;   
  4. std::cout << i << " " << sum << std::endl;