Skip to main content

Section 2.2 Expressions-WE1-P1

Subgoals for evaluating an assignment statement.

  1. Determine resultant data type of expression
  2. Update variable for pre operators based on side effect
  3. Solve arithmetic equation, operator precedence
  4. Is the Left Hand Side (LHS) of the assignment statement a variable? Check the data type of the value on right hand side (RHS) against data type of LHS variable.
  5. Update variable for post operators based on side effect

Subsection 2.2.1

Given
int alpha, beta, gamma;
double omega, theta, lambda;
beta = 1;
omega = 2.5;

Exercises Exercises

1.
    Q1: alpha = beta;
  • valid
  • invalid
2.
    Q2: alpha = omega;
  • valid
  • invalid
3.
    Q3: theta = 22;
  • valid
  • invalid
4.
    Q4: omega = gamma;
  • valid
  • invalid
5.
    Q5: theta = lambda;
  • valid
  • invalid
You have attempted of activities on this page.