Chapter 2 Review Introduction to Programming
Design an algorithm that prompts the user to enter his or her favorite color and stores the user's input in a variable named color.
1.) Get the user's favorite color. 2.) Store the user's favorite color in a variable named height.
Design an algorithm that prompts the user to enter his or her height and stores the user's input in a variable named height.
1.) Get the user's height. 2.) Store the user's height in a variable named height.
If the following pseudocode were an actual program, what would it display? Declare Integer num = 99 Set num = 5 Display num
5
Assume the variables "result", "x", "y", and "z" are all integers, and that x = 4, y = 8, and z = 2. What value will be stored in result in each of the following statements? A.) Set result = x + y B.) Set result = z * 2 C.) Set result = y / x D.) Set result = y - z
A.) 12 B.) 4 C.) 2 D.) 6
Short notes placed in different parts of a program, explaining how those parts of the program work, are called ______. A.) Comments B.) Reference Materials C.) Tutorials D.) External Documentation
A.) Comments
A ______ is a diagram that graphically depicts the steps that take place in a program. A.) Flowchart B.) Step Chart C.) Code Graph D.) Program Graph
A.) Flowchart
A(n) ______ operator performs division, but instead of returning the quotient it returns the remainder. A.) Modulus B.) Multiplication C.) Exponent D.) Operand
A.) Modulus
In the expression 12 + 7, the values on the right and left of the + symbol are called ______. A.) Operands B.) Operators C.) Arguments D.) Math Arguments
A.) Operands
A ______ is a storage location in memory that is represented by a name. A.) Variable B.) Register C.) RAM Slot D.) Byte
A.) Variable
Write assignment statements that perform the following operations with the variables "a" and "b". A.) Adds 2 to a and stores the result in b. B.) Multiplies b times 4 and stores the result in a. C.) Divides a by 3.14 and stores the result in b. D.) Subtracts 8 from b and stores the result in a.
A.) a + 2 = b B.) a = b * 4 C.) b = a / 3.14 D.) a = b - 8
A(n) ______ sets a variable to a specified value. A.) Variable Declaration B.) Assignment Statement C.) Math Expression D.) String Literal
B.) Assignment Statement
Assigning a value to a variable in a declaration statement is called ______. A.) Allocation B.) Initialization C.) Certification D.) Programming Style
B.) Initialization
An informal language that has no syntax rules, and is not meant to be compiled or executed is called ______. A.) Faux Code B.) Pseudocode C.) Java D.) A Flowchart
B.) Pseudocode
A ______ is a single function that the program must perform in order to satisfy the customer. A.) Task B.) Software Requirement C.) Prerequisite D.) Predicate
B.) Software Requirement
A(n) ______ variable is one that has been declared, but has not been initialized or assigned a value. A.) Undefined B.) Uninitialized C.) Empty D.) Default
B.) Uninitialized
A ______ is a hypothetical person that is using a program and providing input for it. A.) Designer B.) User C.) Guinea Pig D.) Test Subject
B.) User
A(n) ______ operator raises a number to a power. A.) Modulus B.) Multiplication C.) Exponent D.) Operand
C. Exponent
A ______ error does not prevent the program from running, but causes it to produce incorrect results. A.) Syntax B.) Hardware C.) Logic D.) Fatal
C.) Logic
A(n) ______ is a variable whose content has a value that is read only and cannot be changed during the program's execution. A.) Static Variable B.) Uninitialized Variable C.) Named Constant D.) Locked Variable
C.) Named Constant
A(n) ______ is a set of statements that execute in the order that they appear. A.) Serial program B.) Sorted Code C.) Sequence Structure D.) Ordered Structure
C.) Sequence Structure
A ______ is a sequence of characters that is used as data. A.) Sequence Structure B.) Character Collection C.) String D.) Text Block
C.) String
A(n) ______ is a set of well-defined logical steps that must be taken to perform a task. A.) Logarithm B.) Plan of Action C.) Logic Schedule D.) Algorithm
D.) Algorithm
A debugging process in which you imagine that you are the computer executing a program is called ______. A.) Imaginative Computing B.) Role Playing C.) Mental Stimulation D.) Hand Tracing
D.) Hand Tracing
A(n) ______ is a message that tells (or asks) the user to enter a specific value. A.) Inquiry B.) Input Statement C.) Directive D.) Prompt
D.) Prompt
A(n) ______ specifies a variable's name and data type. A.) Assignment B.) Variable Specification C.) Variable Certification D.) Variable Declaration
D.) Variable Declaration
Write a pseudocode statement that declares the variable "total" so it can hold integers. Initialize the variable with the value of 0.
Declare Integer total = 0
Write a pseudocode statement that declares the variable "cost" so it can hold real numbers.
Declare Real cost
True or False: Hand tracing is the process of translating a pseudocode program into machine language by hand.
False
True or False: Internal documentation refers to books and manuals that document a program, and are intended for use within a company's programming department.
False
True or False: Programmers must be careful not to make syntax errors when writing pseudocode programs.
False
True or False: The name gross_pay is written in camelCase convention.
False
True or False: Variable names can have spaces in them.
False
Computer programs typically perform what three steps?
Input, Processing, Output
What does the term user-friendly mean?
Refers to programs that are easy to use.
If the following pseudocode were an actual program, what would it display? Declare Integer a = 5 Declare Integer b = 2 Declare Integer c = 3 Declare Integer result Set result = a + b * c Display "Result = ", result
Result = 11
Write a pseudocode statement that assigns the value 27 to the variable "count".
Set count = 27
Write a pseudocode statement that subtracts the variable "downPayment" from the variable "total" and assigns the result to the variable "due".
Set due = total - downPayment
Write a pseudocode statement that assigns the sum of 10 and 14 to the variable "total".
Set total = 10 + 14
Write a pseudocode statement that multiplies the variable "subtotal" by 0.15 and assigns the result to the variable "totalFee".
Set totalFee = subtotal * 0.15
True or False: In a math expression, multiplication and division take place before addition and subtraction.
True
True or False: In languages that require variable declarations, a variable's declaration must appear before any other statements that use the variable.
True
True or False: In most languages, the first character of a variable name cannot be a number.
True
True or False: The value of a named constant cannot be changed during the program's execution.
True
True or False: Uninitialized variables are a common cause of errors.
True
What two things must you normally specify in a variable declaration?
Variable Name, Variable Type
What value is stored in uninitialized variables?
Whatever value happens to be stored at the memory location that variable occupies. Usually referred to these unpredictable values as "garbage".
What does a professional programmer usually do first to gain an understanding of a problem?
Works directly with the customer to determine what the problem is.