Skip to main content

Section 1.13 Assessment: Operation Precedence

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. If = statement, is Left Hand Side (LHS) a variable? Check data type of copied value against data type of variable
  5. Update variable for post operators based on side effect

Exercises Exercises

    1.

    Q1: Given the following, what value is stored in variable alpha?
    int alpha = 0, x = 5, y = 6, z = 2;
    alpha = x + y * z - 1;
    

    2.

    Q2: Given the following, what value is stored in variable beta?
    int beta = 0, x = 5, y = 6, z = 2;
    beta = (y + 3) * (x / 3) - z;
    

    3.

    Q3: Given the following, what value is stored in variable gamma?
    int x = 5, y = 6;
    double gamma = 1.0;
    gamma = gamma * -1.0 + x / y;
    

    4.

    Q4: Given the following, what value is stored in variable delta?
    int delta = 0, x = 5, y = 6, z = 2;
    delta = x % y * z % y;
    

    5.

    Q5: Given the following, if iota contains the value 32, what must be the value stored in variable eta?
    int eta = ??;
    int iota = (eta + 5) * (5 % eta + 2);
    
You have attempted of activities on this page.