Schedule‎ > ‎

Midterm 1 Review Supplement

Midterm 1 Review Supplements

Instructions

  • Take out a piece of paper and put your name on the paper.
  • Your work will be reviewed and graded, so make it presentable.
  • We will complete as many of the following sections as we have time during class.
  • The rest of the sections are to be completed at home and are due the day of the test.
  • For those sections completed at home, review by another student is optional.

^ top

Variables and Assignment (5m)

  1. Write the heading for this problem on your paper.
  2. In Lesson 3A review Review of Variables
  3. On your paper, declare a variable and assign a value for storing each of the following types of data:
    • Dollars and cents
    • The count of the number of people in a room
    • A single letter
    • Whether or not an LED is on or off
  4. Write the value of a and b on your paper after the following code snippet executes
    int a = 10;
    int b = 20;
    a = b;
    
    a is ________ b is ________
  5. Exchange papers with another student in the class for grading.
  6. When grading, mark the number correct and the number of questions next to the problem heading, like: 5 / 6. (1m)
  7. Return the papers, discuss the grading and ask questions.

Test Yourself (Optional)

  1. The problem with the following code snippet is ________.
    int value;
    value = 1.23;
    
    1. The "value" variable is never initialized.
    2. The data type for the "value" variable is not specified.
    3. The "value" variable is never assigned a value.
    4. The "value" variable is assigned a decimal value, but it can store only a whole number value.
  2. In an airline reservation system, the cost of an airline ticket is required. The data type that should be used to store this value is a single ________.
    1. int
    2. bool
    3. double
    4. char

^ top

Conditional Statements (4m)

  1. Write the heading for this problem on your paper.
  2. In Lesson 3B review Using if-else Statements and Nested if Statements.
  3. On your paper, write a solution to the following problems:
    1. The value of x after the following code executes is ________.
      int x = 7;
      if (x == 3) {
        x = 1;
      }
      
    2. The value of x after the following code executes is ________.
      int x = 3; // was x = 7
      int y = 4;
      if (x < y) {
        x = y;
      }
      
    3. The value of x after the following code executes is ________.
      int x = 5; // was x = 7
      if (x > 3) {
          x = x - 2;
      }
      else {
          x = x + 2;
      }
      
    4. The following code snippet prints ________.
      int x = 1; // was x = 7
      if (x > 0) {
        x = x + 5;
      } else if (x > 1) {
        x = x + 2;
      } else {
        x = x + 7;
      }
      Serial.println(x);
      
  4. Exchange papers with another student in the class for grading.
  5. When grading, mark the number correct and the number of questions next to the problem heading, like: 3 / 4. (1m)
  6. Return the papers, discuss the grading and ask questions.

^ top

Electricity and Resistance (3m)

  1. Write the heading for this problem on your paper.
  2. In Lesson 4A review Ohm's Law, Reading Resistors and Voltage Dividers .
  3. On your paper, write a solution to the following problems:
    1. The colored bands for a 560 ohm resistor with a five percent tolerance are: ________.
    2. If you make a voltage divider circuit with R1 = 10K and R2 = 10K, and your Vin is 12V, your Vout is ________.
  4. Exchange papers with another student in the class for grading.
  5. When grading, mark the number correct and the number of questions next to the problem heading, like: 2 / 2. (1m)
  6. Return the papers, discuss the grading and ask questions.

Test Yourself (Optional)

  1. The colored bands for a 4,700 ohm resistor with a ten percent tolerance are ________.
    1. yellow, violet, orange, gold
    2. yellow, violet, red, silver
    3. yellow, violet, red, gold
    4. orange, violet, red, silver
  2. If you make a voltage divider circuit with R1 = 10K and R2 = 10K, and your Vin is 12V, your Vout is ________.
    1. 12v
    2. 10v
    3. 6v
    4. 5v

^ top

Numbers and Computations (3m)

  1. Write the heading for this problem on your paper.
  2. In Lesson 4B review Arithmetic, Integer Division and Modulus and Mathematical Functions.
  3. On your paper, write a solution to the following problems:
    1. First operation performed in 1 + 2 * 3 / 4 % 5 is ________.
    2. The value of x after the following code executes is ________.
      double x = 9 / 4;
      
    3. The value of x after the following code executes is ________.
      double x = pow(3, 2);
      
  4. Exchange papers with another student in the class for grading.
  5. When grading, mark the number correct and the number of questions next to the problem heading, like: 2 / 3. (1m)
  6. Return the papers, discuss the grading and ask questions.

^ top

Characters and Strings (3m)

  1. Write the heading for this problem on your paper.
  2. In Lesson 4B review Joining Strings (Concatenation), and String Functions.
  3. On your paper, write a solution to the following problems:
    1. The value of s3 after the following code executes is ________.
      String s1 = "Hi ", s2 = "Mom!";
      String s3 = s1 + s2;
      
    2. The following code displays ________.
      String message = "Hi mom!";
      Serial.println(message.length());
      
    3. The following code displays ________.
      String message = "Hi mom!";
      Serial.println(message.substring(3, 6));
      
  4. Exchange papers with another student in the class for grading.
  5. When grading, mark the number correct and the number of questions next to the problem heading, like: 2 / 3. (1m)
  6. Return the papers, discuss the grading and ask questions.

^ top

Function Definitions (5m)

  1. Write the heading for this problem on your paper.
  2. In Lesson 5A review Defining a Function and Flow of Control for a Function Call.
  3. On your paper, write a solution to the following problems:
    1. The following code snippet prints ________.
      int x = 12;
      void setup() {
        Serial.begin(9600);
        int x = 2;
        x = x + 7;
      }
      void loop() {
        cout << x << endl;
      }
      
    2. Write a function named add that takes two parameters, sums the parameters and returns the sum as a type double.
  4. Exchange papers with another student in the class for grading.
  5. When grading, mark the number correct and the number of questions next to the problem heading, like 7 / 8, using the following criteria for the second problem. (1m)
    • Correct return type: 1 point
    • Correct function name: 1 point
    • Correct parameter syntax and data type: 2 points (1 point each parameter)
    • Correct function body syntax like curly brace placement, no semicolon after parenthesis, etc: 1 point
    • Correct calculation statement inside the function body: 1 point
    • Correct return statement: 1 point
  6. Return the papers, discuss the grading and ask questions.

^ top

Variable Scope (4m)

  1. Write the heading for this problem on your paper.
  2. In Lesson 5A review Variable and Parameter Scope, Constants and Magic Numbers and Static Variables.
  3. On your paper, write a solution to the following problems:
    1. The following code snippet prints ________.
      int x = 12;
      void setup() {
        Serial.begin(9600);
        x = 2;
        x = x + 7;
      }
      void loop() {
        cout << x;
      }
      
    2. Declare a global constant variable and assign it the value of π (3.14159265359).
    3. Declare a local static int variable named "save" and assign it the value zero (0).  Add 1 to this variable every time the loop runs.  Print out:  " save = " followed by the vaue for save.  What will the output look like?   How is it different if you don't use the static keyword?
  4. Exchange papers with another student in the class for grading.
  5. When grading, mark the number correct and the number of questions next to the problem heading, like: 2 / 3. (1m)
  6. Return the papers, discuss the grading and ask questions.
Comments