Module 1 discussion
An algorithm is classically defined as a finite series of
steps which solves a problem. What are some types of instructions which occur
in everyday life which would qualify as an algorithm? What are some everyday
types of instruction which would NOT qualify as an algorithm?
Module 2 discussion
What are some different types of data you would expect to
manipulate, and how would you represent them in a program?
Module 3 discussion
Consider the numbers of variables and decisions that go into
a complex decision. Consider a real life decision process with which you are
familiar, and list all variables that go into the process. Then express the
process as an algorithm with nested selection structures.
Module 4 discussion
Describe a procedure you use in everyday life in which you
repeat a series of steps over and over again until some condition is met. Can
you describe one that would be considered a nested repetition structure?
Module 5 discussion
What procedures in your daily routine, say getting up and
leaving for work, can you think of in terms of a function? How does this
abstraction help you deal with the complexity of your life?
Module 6 discussion
Discuss some of the advantages and pitfalls of using arrays
in a C++ program.
Module 7 discussion
How would most people use a PC if it did not support text?
What applications would remain possible, and what others would be too unwieldy
to use practically?
Module 8 discussion
How useful would a computer be if you did not have secondary
storage?
Module 1 Hands on learning
Please complete the following exercises:
Chapter 2, Exercises: 1 and 5, p. 45
Chapter 2, Exercise: 8, p. 46
Module 2 Hands on learning
Please complete the following exercises:
Chapter 3, Exercises 4 and 6, p. 72
Chapter 4, Exercise 11, p. 107
Chapter 4, Exercise 14, p. 108
Module 3 Hands on learning
Please complete the following:
Chapter 5, Lab 5-1, pp. 137-138
Chapter 5, Computer Exercise 11, p. 150
Chapter 6, Lab 6-1, pp. 177-178
Chapter 6, Computer Exercise 13, p. 191
Module 4 Hands on learning
Please complete the
following:
Chapter 7, Lab 7-2, pp. 230-233
Chapter 7, Computer Exercise 19, p. 241
Chapter 8, Lab 8-2, pp. 263-267
Chapter 8, Computer Exercise 18, p. 274
Module 5 Hands on learning
Please complete the following:
Chapter 9, Lab 9-2, pp. 307-314
Chapter 9, Computer Exercise 16, pp. 322-323
Chapter 10, Lab 10-2, pp. 347-355
Chapter 10, Computer Exercise 16, pp. 363-364
Module 6 Hands on learning
Please complete the following:
Chapter 11, Lab 11-2, pp. 407-411
Chapter 11, Computer Exercise 20, p. 418
Chapter 12, Lab 12-2, pp. 446-449
Chapter 12, Computer Exercise 23, p. 454
Module 7 Hands on learning
Please complete the following:
Chapter 13, Lab 13-2, pp. 492-497
Chapter 13, Computer Exercise 20, p. 506
Chapter 13, Computer Exercise 21, p. 506
Chapter 13, Computer Exercise 25, p. 506
Module 8 Hands on learning
Please complete the following:
Chapter 14, Lab 14-2, pp. 530-539
Chapter 14, Computer Exercises 19 and 20, p. 546
Module 8 final exam
Question 1 You can
use the built-in C++ __________ function to raise a number to a power and then
return the result as a double number.
xy()
raise()
pow()
power()
Question 2 A(n) __________ is a block of code that performs
a task.
program
expression
statement
function
Question 3 Unless specified otherwise, variables are passed
by __________ in C++.
reference
copy
address
value
Question 4 For a program to create a file object, it must
contain the __________ directive.
#include <ostream>
#include <fstream>
#include <iostream>
#include <istream>
Question 5 A __________ function uses its return value to
send information back to the function that called it.
value-returning
built-in
program-defined
void
Question 6 Of the formal parameters in the replace function,
__________ is optional.
replacementString
count
none of the above
subscript
Question 7 The
__________ statement replaces the letter located in position 3 in the item
variable, with the letter “D”.
item.replace("D", 3);
item.replace(3, 1, "D");
item.replace(3, "D");
item.replace(1, 3, "D");
Question 8 __________ declares and initializes a
five-element double array named prices; the first element is initialized to
6.5, while the others are initialized to 0.0.
double prices[5] = {6.5,,,,};
double prices[] = {6.5};
double prices[] = {6.5,,,,};
double prices[5] = {6.5};
Question 9 The statement __________ opens the payroll.txt
file for output.
outFile.open(ios::app, "payroll.txt");
outFile.open(ios::out, "payroll.txt");
outFile.openOut("payroll.txt");
outFile.open("payroll.txt");
Question 10
Executing:
string phone = "3120501111";
phone.insert(0, "(");
phone.insert(__________ , ")"); // Fill in the
blank
phone.insert(8, "-");
changes the contents of the phone variable to
“(312)050-1111”.
5
3
4
6
Question 11 Every C++ program contains at least one
function: __________.
return()
rand()
main()
pow()
Question 12 When passing a two-dimensional array, the
__________ set of square brackets in the formal parameter of a function header
or prototype may be left empty.
both first and second
first
neither first nor second
second
Question 13 Connecting strings together is called
__________.
concatenating
joining
uniting
linking
Question 14 A(n) __________ is a group of variables that
have the same name and data type and are related in some way.
scalar variable
array
object
class
Question 15 _________ assigns a user-entered value to the
element located in the third row, second column of the grades array.
cin<< grades[2][1];
cin<< grades[3][2];
cin>> grades[3][2];
cin>> grades[2][1];
Question 16 When referring to an element in an array, the
element’s subscript must be placed between __________.
[]
‘’
“”
{}
Question 17 __________ assigns the character F to the variable
located in the second row, first column of the grades array.
grades[1][0] = 'F';
grades[0][1] = 'F';
grades[1][2] = 'F';
grades[2][1] = 'F';
Question 18 The
__________ is the Not logical operator in C++.
~
!
#
^
Question 19 Consider the array declared using the double
prices[2][4] = { { 2.99, 14.99, 8.99, 24.99 }, { 1.99, 12.99, 6.99, 20.99 } };
statement. The statement prices[1][2] = prices[0][2]; will replace the number
__________.
20.99 with 24.99
8.99 with 6.99
12.99 with 14.99
6.99 with 8.99
Question 20 __________ declares and initializes a
four-element string array named sales; each element is initialized to 0.0.
string sales[4] = {0.0, 0.0, 0.0, 0.0};
string [4]sales = {0.0};
string sales[] = {0.0};
string sales[4] = {};
Question 21 In C++
you can use the __________ function to access any number of characters
contained in a string variable.
access
substr
charAt
substring
Question 22 The
__________ statement shows the prototype of a function that receives an array
of double elements.
voiddisplayArray(double []);
voiddisplayArray(double);
voiddisplayArray(double *);
voiddisplayArray(double [*]);
Question 23 In C++, two-dimensional arrays are automatically
passed __________ to functions.
by reference
by address
by value
by subscript
Question 24 Executing:
string name = "Rob Smith";
name.insert(4, "T. ");
changes the contents of the name variable to __________.
“Rob T. Smith”
“Rob T.Smith”
“RobT.Smith”
“RobT. Smith”
Question 25 The
computer uses a file __________ to keep track of the next character either to
read from or write to a file.
stream
iterator
pointer
object
Module 4 midterm exam
Question 1 The __________ step to creating a computer
solution is to analyze the problem.
third
first
second
fourth
Question 2 Between the switch statement’s opening and
closing braces are the individual __________ clauses.
if
else
case
if/else
Question 3 You can use a(n) __________ to help you
desk-check an algorithm.
flowchart
pseudocode
IPO chart
desk-check table
Question 4 If the default clause is not the last clause in
the switch statement, you will need to include a __________ statement at the
end of the clause to stop the computer from processing the instructions in the
next case clause.
stop
break
continue
switch
Question 5 The evaluation of the condition in a __________
loop occurs before the instructions within the loop are processed.
for
pretest
while
posttest
Question 6 The do while statement must end with a(n) __________.
;
.
,
//end do while comment
Question 7 The __________ step to creating a computer
solution is to code the algorithm into a program.
third
second
fourth
fifth
Question 8 A program that displays a message based on a
letter grade that the user enters would require a(n) __________ selection
structure.
nested
multiple-alternative
if
else
Question 9 The __________ condition tells the computer when
to stop looping through the instructions.
repeat
continue
loop exit
looping
Question 10 In the code shown below, the computer continues
processing the inner loop’s instructions until the user enters __________, at
which time the inner loop ends.
int sales = 0;
int region = 1;
inttotRegSales = 0;
while (region < 3)
{
cout<< "First sales amount for Region "
<<region<< ": ";
cin>> sales;
while (sales > 0)
{
totRegSales = totRegSales + sales;
cout<< "Next sales amount for Region "
<<region<< ": ";
cin>> sales;
} //end while
cout<<endl<< "Region " <<
region << " sales: $"
<<totRegSales<<endl<<endl;
region = region + 1;
totRegSales = 0;
} //end while
cout<< "End of program" <<endl;
a negative number
a number greater or equal than 3
the number 0
either the number 0 or a negative number
Question 11 __________ means to assign a beginning value to
a counter or accumulator variable.
Flushing
Iterating
Accumulating
Initializing
Question 12The __________ combines the object file with
other machine code necessary for your C++ program to run correctly.
interpreter
assembler
linker
compiler
Question 13The linker produces a(n) __________ file, which
is a file that contains all of the machine code necessary to run your C++
program as many times as desired without the need for translating the program
again.
source
executable
object
include
Question 14 In the code shown below, the __________ clause
begins the inner loop.
int sales = 0;
int region = 1;
inttotRegSales = 0;
while (region < 3)
{
cout<< "First sales amount for Region "
<<region<< ": ";
cin>> sales;
while (sales > 0)
{
totRegSales = totRegSales + sales;
cout<< "Next sales amount for Region "
<<region<< ": ";
cin>> sales;
} //end while
cout<<endl<< "Region " <<
region << " sales: $"
<<totRegSales<<endl<<endl;
region = region + 1;
totRegSales = 0;
} //end while
cout<< "End of program" <<endl;
inttotRegSales = 0;
while (region < 3
cin>> sales;
while (sales > 0)
Question 15 An assignment statement __________ create(s) a
variable in memory.
does not
always
may not
may
Question 16 In a for clause, the __________ argument
specifies the condition that must be true for the loop to continue processing
the loop body instructions.
last
first
second
third
Question 17 A __________ is a C++ instruction that causes
the computer to perform some action after it is executed, or processed, by the
computer.
directive
processing item
statement
keyword
Question 18 Consider the following pseudocode:
1. enter the
code and sales amount
2. calculate
the bonus amount by multiplying the sales amount by .08
3. if (the
code is X)
if (the sales are greater than or equal to 10000)
add 150 to the bonus amount
else
add 125 to the bonus amount
end if
end if
4. display
the bonus amount
If the code is X and the sales amount is 15000, the value of
the bonus amount at the end of the algorithm in the accompanying figure will be
__________.
1200
845
1350
720
Question 19 Logical operators are sometimes referred to as
__________ operators.
Relational
Comparison
Conditional
Boolean
Question 20 The first of two diamonds encountered along a
path in a flowchart represents the condition of the __________ selection
structure of a nested selection structure.
switch
inner
nested
outer
Question 21 In a flowchart, the oval symbol is called the
__________ symbol.
process
selection
start/stop
input/output
Question 22 The And operator in C++ is __________.
!
||
&&
&
Question 23 The selection structure is also called the
__________ structure.
diamond
switch
decision
case
Question 24 __________ an algorithm refers to the process of
translating the algorithm into a language that the computer can understand.
Assembling
Translating
Coding
Tracing
Question 25 The processing portion of an IPO chart might
include a __________.
statement about the input data
statement about the output dat
notation to the user of the program
flowchart