Sams Teach Yourself C++ in 21 Days

(singke) #1
Answers 825

D



  1. a. Good
    b. Not legal
    c. Legal, but a bad choice
    d. Good
    e. Legal, but a bad choice


Exercises ........................................................................................................


  1. The following are appropriate answers for each:
    a. unsigned short int
    b. unsigned long intor unsigned float
    c. unsigned double
    d.unsigned short int

  2. The following are possible answers:
    a. myAge
    b. backYardArea
    c. StarsInGalaxy
    d.averageRainFall

  3. The following is a declaration for pi:
    const float PI = 3.14159;

  4. The following declares and initializes the variable:
    float myPi = PI;


Day 4....................................................................................................................


Quiz ................................................................................................................


  1. An expression is any statement that returns a value.

  2. Yes, x = 5 + 7 is an expression with a value of 12.

  3. The value of 201 / 4 is 50.

  4. The value of 201 % 4 is 1.

  5. Their values are myAge: 41,a: 39,b: 41.

  6. The value of 8+2*3 is 14.
    7.if(x = 3)assigns 3 to xand returns the value 3 , which is interpreted as true.
    if(x == 3)tests whether xis equal to 3 ; it returns true if the value of xis equal to
    3 and false if it is not.


32 0672327112_app_d.qxd 11/19/04 12:30 PM Page 825

Free download pdf