c2.3 p38 PRACTICE!

   Give the value computed by each of the following sets of statements:
   (using double here instead of float)

   1: int a=27, b=6, c;
      . . .
      c = b%a;

   2: int a=27, b=6;
      double c;
      . . .
      c = a/(double)b;

   3: int a;
      double b=6, c=18.6;
      . . .
      a = c/b;

   4: int b=6;
      double a, c=18.6;
      . . .
      a = (int)c/b;

c2.3 p40 PRACTICE!

In Problems 1 through 3, give C statements to compute the indicated values.
Assume that the identifiers in the expressions have been defined as double
variables and have also been assigned appropriate values.

Use the following constant:

   Acceleration of gravity: g = 9.80665 m/s2

     1.  Distance traveled:

     

     2.  Tension in a cord:

     

     3.  Fluid pressure at the end of a pipe:

     

In Problems 4 through 6, give the mathematical equations computed by the C
statements. Assume that the following symbolic constants have been defined,
where the units of G are m3/(kg  s2):

#define PI (4*atan(1))  /* full precision, better than using 3.14... */
#define G 6.67259e-11

     4.  Centripetal acceleration:

centripetal = 4*PI*PI*r/(T*T);

     5.  Potential energy:

potential_energy = -G*M_E*m/r;

     6.  Change in potential energy:

change = G*M_E*m* (1/R_E - 1/(R_E + h));

c2.3 p43 PRACTICE!

Give a memory snapshot after each statement is executed, assuming that x is
equal to 2 and that y is equal to 4 before the statement is executed.

Also, assume that all the variables are integers.

     1: z = x++*y;

     2: z = ++x*y;

     3: x += y;

     4: y %= x;