Next: Exercises Up: The Assignment statement Previous: Multiple Choice Questions

Review questions

  1. Write C++ expressions for the following mathematical formulae:

    \begin{displaymath}
\begin{array}{cccc}
\displaystyle{b^2-4ac} &
\displaystyle{ ...
...aystyle{\frac{1}{1+x^2}} &
\displaystyle{ a*-(b+c)}
\end{array}\end{displaymath}

  2. Write C++ statements to change an integer number of centimetres into the equivalent in kilometres, metres and centimetres. For example 164375 centimetres is 1 kilometre, 643 metres and 75 centimetres. Include declarations of suitable variables.
  3. To what do the following expressions evaluate?
         17/3  17%3  1/2  1/2*(x+y)
    

  4. Given the declarations:
    float x;
    int k, i = 5, j = 2;
    
    To what would the variables x and k be set as a result of the assignments



Next: Exercises Up: The Assignment statement Previous: Multiple Choice Questions