Exam 1 Review

Here are some sample questions for you to try out before you take the first exam. Note that some of these are in the form of multiple choice/True-False, and the actual exam will not be that kind. I will ask questions on the important concepts we have been studying, and you get to explain them to me. I am hoping that working through these questions will get you ready to explain those concepts.

Here are the sample questions:

Introduction

  1. A precise list of instructions we want a computer to follow is called a _____.

  2. Computers are very smart
    • True
    • False
  3. Most people can succeed in their jobs without knowing much about computers.
    • True
    • False
  4. Computer programs are written in some programming ______.

  5. Are we having fun yet?
    • True
    • False

Binary Numbers

  1. The characters we use for our normal numbers are called:
    • Numbers
    • Symbols
    • Characters
  2. The number system that uses ten symbols is called the _______ system
    • base ten
    • normal
    • decimal
  3. The number system used by computers that has only two symbols is called the ______ system
    • base two
    • binary
    • discrete
  4. The first electronic computer was named:
    • HAL
    • IBM
    • ENIAC
    • MAC
  5. What is the next number in the binary number system after 11?
    • 12
    • 100
    • 110
  6. What is the decimal number equivalent of the binary number 101?
    • 11
    • 3
    • 5
    • 6
  7. A transistor is just a fancy electronic _______

  8. Computers can manipulate any kind of data we can
    • encode as binary numbers
    • invent a device to attach to the computer to read the data
    • convert into decimal symbols

Hardware Overview

  1. We store programs and data in the computer’s ________

  2. Which one of these components is not part of a Von Neuman computer system?
    • Memory
    • Arithmetic/Logic unit
    • Control Unit
    • Monitor
  3. The place in the computer where we would compare two numbers is the ________
    • Control unit
    • Memory unit
    • Arithmetic/Logic unit
    • Input/output unit
  4. Can you draw a diagram of the Von Neuman Computer and label it’s parts?
    • true
    • false
  5. The electronic device that was invented in the early 1950’s that let computers get very small is a _______

  6. The computer processes instructions as the system _________ ticks

  7. What is the processing step in the sequence of actions the computer does after decode?

  8. Can you name the sequence of actions taken by the processor as it runs each instruction in your program?
    • true
    • false
  9. In the Pentium computer eight bits is called a _______

  10. A large series of bytes each numbered from zero to some large value is called the _________

  11. The two basic kinds of memory we find in a computer are read/write and read only
    • true
    • false
  12. When we turn off the power to a computer, the program remains in memory.
    • true
    • false
  13. The memory we use to store programs while the computer is turned off is called flash memory
    • true
    • false

Problem Solving

  1. When we start working on a problem, we need a good ________________ statement

  2. The first thing we do in solving the problem is to _______________ the problem

  3. The fancy term for the series of steps we want a computer to follow to solve a problem is an ________________

  4. At any point in time while a computyer is working through your program, we say that the program is in some specific ____________
    • state
    • country
    • computer
  5. The use of proper indentation in a progrma leads to good program ______________

  6. Since modern programming languages can have blanks just about anywhere, we do not need to worry about program style.
    • true
    • false
  7. The rules for writing a program are different for different programming _______________

  8. You should understand your programming language well enough to be able to manually walk your program through its steps.
    • true
    • false
  9. Before you can be sure your program works properly, you should ____________ your program.

  10. We can make a sprite move in our program by assigning new values to the position variables.
    • true
    • false
  11. The symbol “<” is used to
    • indent program code
    • compare two numbers
    • mark a line
  12. To make a sprite move at an angle, we need to
    • change just the x position variable
    • change just the y position variable
    • change both x and y position variables
  13. Can you explain how we made the sprite move around on the stage and bounce off the walls?
    • true
    • false
  14. The speed of the ball in the up and down direction is controlled by
    • changing the value we use to modify the x position each time through the loop
    • changing the value we use to modify the y position each time through the loop
  15. We made the ball bounce off of a wall by
    • changing the sign on the amount we use to modify the position
    • exchange the x and y values
  16. To make changing the speed of the sprite easier we introduced deltaX and deltaY. Each of these two names define a program _______________

Expressions

  1. Which of the following names is a good one for a variable?
    • X42
    • Something
    • junk
    • IncomeAmount
  2. The statement we use to modify the value of a variable is called an __________ statement.

  3. In an assignment statement, the part on the right side of the equal sign is an _______________

  4. We call the program construct “sqrt(x)” a _____________

  5. When the computer processes an expression, we say it ____________ the expression

  6. When we create a new variable, we need to _________________ it so it has a know value.

  7. The “+” symbol is called a mathematical _______________

  8. The “*” symbol identifies the mathematical ________________ operation

  9. The percent sign is used to evaluate
    • The percent value of an expression
    • The difference between two numbers
    • The product of two numbers
    • The remainder after division of two integer numbers
  10. A number with no fractional part is called an ________________

  11. When is the result of the expression “5/2”? (Integers here!)
    • 3
    • 2.5
    • 2
    • 0
  12. What is the result of the expression “5%2”?
    • 3
    • 2
    • 1
    • 2.5
  13. The computer processes expressions basically from left to right.
    • true
    • false
  14. When the computer sees a variable name in an expression
    • It uses the value stored in that variable
    • It asks the user what value to use
    • It halts since it does not know what to do
  15. Operator precedence is a term that explains
    • How two operators are related to each other
    • which operators will be evaluated first in an expression
    • Which operator comes before another operator
  16. When you have a complicated expression, you can use ____________ to tell the computer how to evaluate parts the expression

  17. multiplication and addition have higher precedence than division and subtraction
    • true
    • false
  18. addition and subtraction have the same precedence
    • true
    • false
  19. Can you take an expression and “fully parenthesize” it?
    • true
    • false
  20. Can you give an example of using the “mod” operator in a program?
    • true
    • false

Encoding Data

  1. Suppose you discovered that sound is just air particles vibrating at a certain rate (frequency). You also discovered a device that can measure the vibrations and produce an electrical voltage between 0 and 5 volts - corresponding to the full range of sounds you can hear. 0 volts means no sound, and 5 volts means a very high pitched sound - so high you can barely make it out! If we want to teach the computer to store and analyze sound, how would we encode that data? We want to come up with an encoding that will give us good accuracy in recording the frequency.

Standard Data Types

  1. What are the fundamental data types we have learned so far, and give an example of a literal value for each type.
  2. What does the term Data Type mean. (That is, what does the computer know about a data type?)

Declaring and Initializing Variables

  1. Show a declaration of a variable suitable for storing your age in years.
  2. Show a declaration suitable for storing your precise height.
  3. How do we initialize the variables we defined above?

Fundamental programming structures

  1. Draw diagrams for the three fundamental programming structures.

Assignment Statements

  1. An assignment statement is written like this: A = expression;. Explain what the computer will do when it processes this statement.

Expressions

  1. What is an expression? Give examples of places where you will need to write expressions in your programs.
  2. How are parentheses used in expressions? How does the computer process an expression containing parentheses?

Math Operators and Precedence

  1. List the four fundamental math operators.
  2. In an expression using all of the operators above and no parentheses, how will the computer process the expression?

Logical Operators

75, What is the difference between an expression that performs math, and a
logical expression?
  1. Show an expression that determines if the number num is between big and little.

Decision Statements

If-Then-Else Statements

  1. Show an if-then-else statement that displays the text “Hello World” if the value of the variable mood is greater than 5, and displays the text “go away” otherwise.

Switch Statements

  1. Show a switch statement that displays the even numbers from 0 to 10

Looping Statements

While-Loop

  1. Show how to write a while-loop that displays the even numbers from 0 to 10.

Do-While-Loop

  1. Show how to write a do-while-loop that displays the even numbers from 0 to 10.

For-Loop

  1. Show how to write a for-loop that displays the even numbers from 0 to 10.

Value Functions

  1. Why do we use functions in programming?
  2. Show how to write a function that adds two integer numbers and returns the sum.
  3. Show how to use the function you wrote in the last question.

Functions with no value

  1. Show how to write a functions that returns no value.
  2. Show how to call the function you wrote above.
  3. Why would we write a function that returns no value?

Developing programs with functions

  1. What is a stub and why would we write one?

  2. Explain how functions can help write programs using

    Baby Steps.