# Subgoals

## Section1.31Assessment: Swap

### 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

### ExercisesExercises

#### 1.

Q1: After executing the following code, the value in variable a is and the value in variable b is .
int a = 1;
int b = 2;
a = 3;


#### 2.

Q2: After executing the following code, the value in variable r is and the value in variable s is .
int r = 2;
int s = 4;
r = s;


#### 3.

Q3: After executing the following code, the value in variable p is and the value in variable q is .
int p = 1;
int q = 8;
q = p;
p = q;


#### 4.

Q4: After executing the following code, the value in variable x is , the value in variable y is , and the value in variable z is .
int x = 7;
int y = 5;
int z = 3;
x = y;
y = z;
z = x;


#### 5.

Q5: Suppose there are four integer variables a,b,c, and d as depicted below. The code beside the diagram is intended to move the values in those variables one place clockwise, but two statements are missing. Choose the option that has the correct 2 statements.