Exercises

Please complete each exercise or answer the question before reviewing the posted solution comments.

Use the clear command before starting your work on a new problem to ensure that any existing variable name assignments don't interfere with your work on the new problem.

  1. What happens when you enter the following at the Command Window? Why?

    >> 3 = p + q
      	>> 3 = q + p
      	??? 3 = q + p
      	      |
      	Error: The expression to the left of the equals sign is not a valid target for an assignment.
      
      	>>     

    This error is generated because it doesn't make sense to assign a new value ( q + p ) to a constant value ( 3 ). You can only assign values to single variable names.

  2. What is the difference between assignment and equality?

    Assignment uses an = as an operator. The assignment operator is used to set a variable to a specific value.

    Equality implies that the expressions on both the left hand side and the right hand side of are equal. This concept does not really exist in numerical programming environments. Later in the course, we will see how we can compare two expressions to see if their current values are equal. But, we will not be able to set such a relationship.