Some questions on assignment statements

  1. What is wrong with the following assignment statements?
    1. x == i+3;
      Comparison operator (==) used instead of assignment (=).
    2. j = i * j
      Semi-colon missing at the end of the statement.
    3. i + 3 = j -k;
      left hand side of the assignment is not a variable, but an expression instead.
  2. Write a program to read in three numbers, find their mean and range and write out the original numbers and the two results calculated.
    A sample solution is here.

Some answers to these questions.


Back to the notes on assignment.