• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

BMS Processing Class

A Course23.com Production

"Stop, Pause, and Think..." -- Ms. Elwell
"Take your time, it isn't a race" -- Mr. Helmke

  • Home
  • Graphing and Color
    • Graphing Shapes
      • Activity 1
      • Activity 2
    • Color (R,G,B) and Grey Scale
      • Activity 3
      • Activity 4
  • Code and Sketches
    • Parts of Code
      • Activity 5
    • Your Code & OpenProcessing Sketches
      • Activity 6
      • Activity 7
  • Variables, etc
    • Variables
      • Activity pre8 and 8
      • Activity 8.1
      • Activity 9
      • Activity 10
      • Activity 11
      • Activity 11.1
    • Operator Precedence
      • Activity 12
      • Activity 13
    • Random
      • Activity 14
      • Activity 15
  • Conditionals – If, Else, Else If
  • Resources

Activity 12

Use your Notebook.

For each of the following examples, answer the questions. It is recommended that you solve for each line of code first and then you will have the answers readily available to you.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// 1. Given the following code:
 
var x = 20;
var y = 30;
var z, q;
 
z = x + y;  // (a)
q = z - x;
y = 40;
z = x + y;  // (b)
 
// Answer:
 
// 1a. what is the value of z at (a):________________________________
 
// 1b. what is the final value of q:_________________________________
 
// 1c. what is the value of z at (b):________________________________
 
// 2.  Given the following code:
 
var x = 1;
var y = 2;
var z = 3;
var p, q, r;
 
p = x + y;
q = y * 2 + z;
r = x + y * z;
 
// Answer:
 
// 2a. what is the final value of p: ______________________
 
// 2b. what is the final value of q: ______________________
 
// 2c. what is the final value of r: ______________________
 
// 3.  Given the following code:
 
var x = 10;
var y = 30;
var z = 25;
var a, b;
 
a = x + y + z;
x = x + y;
z = x + y;
b = a + z;
 
// Answer:
 
// 3a. what is the final value of a:__________________
 
// 3b. what is the final value of x:__________________
 
// 3c. what is the final value of z:__________________
 
// 3d. what is the final value of b:__________________

Go back to:  Operator Precedence

Primary Sidebar

Required Reading:

Course Coding Standards

Copyright © 2016–2021 Chris Elwell/Michael Helmke · This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License · Log in