CMPE003
Personal Computer Concepts: Software and Hardware
Spring 1996
Exam2 Sample
NAME:___________________ ID#:_____________
COMPUTER ENGINEERING 03 - SPRING 1993 P.E. MANTEY MIDTERM 2
Test t Page 1
Instructions:
Mark ALL your answers on the Answer Sheet provided. NO
credit will be given for answers on this test paper. For
multiple choice questions, choose the SINGLE best answer.
If you have any questions, raise your hand and, if
appropriate, we will answer them.
Part 1: Multiple Choice/Fill in the Blank, 2 points each:
1. In Pascal, the code in a procedure is only executed when the
procedure is
a. called
b. declared
c. compiled
2. In Pascal, a "parameter" is used to pass information from
the main program to ______________
3. To use a procedure in Pascal you need
a. to re-declare the procedure each time you call it
b. to declare the procedure or call it; these actions are
identical
c. to declare the procedure and call it in the body of the
program
d. only to declare it
e. to call it in the body of the program
4. In Quattro-Pro, when the first character in the cell is an
"+", then the cell should contain a(n)
_____________________.
5. In computer circuits, the "flip/flop" is used for what
computer function (what part of the von Neuman
architecture)?
a. clock
b. logic
c. memory
6. In Pascal, "assignment" of a variable is the name given
to ...
a. specifing a storage location for a variable
b. storing a value in that variable
c. declaring the type of a variable
7. The highest programming language "level" where programmers
must manage hardware parts such as registers is at the
_______________ language level.
8. In Pascal, if you want the variable called "hits" to take on
values which are whole numbers (no fractional part) it
should be declared as type _________.
9. In a Pascal program, if you want a program statement to be
ignored or othewise have no effect upon execution of the
program, you can
a. precede the statement with the word "ignore"
b. put the statement inside double quotation marks
c. put the statement inside single quotation marks
d. make it into a comment by enclosing it with "{ }"
10. In computer programming, the sequence of instructions that
solves a problem or task is called an ___________________
11. If you look at a computer program, and it is made up
entirely of numbers, the program code you see is in
a. machine language
b. a high-level language
c. assembly language
d. FORTRAN
12. In computer programming, "divide and conquer" refers to
a. a computer game
b. decomposing problems into smaller units to be solved
separately
c. a Department of Defense battle simulation
13. In using Turbo Pascal, the program that turns your Pascal
statements into an assembly program is called a
_____________.
14. Which of the following is NOT true about comments in a
Pascal program?
a. they are used to help humans understand the program
b. they help Turbo Pascal discover semantic errors in a
program
c. they are used to help humans debug a program
d. they are helpful in allowing others to extend or
maintain a program
15. To use the same specific value from cell B22 in a forumla in
a range of cells created by copying a single cell, it should
be used in the formula as: ____________
16. The "case" statement is another form of what statement?
a. while
b. repeat
c. for
d. if
17. What is the error in the following Pascal code? (Assume
inning is declared as integer)
if inning >= 8 then
begin
WriteLn('Game may be about over!');
WriteLn('Unless score is close')
end;
else
WriteLn('Buy some more popcorn');
a. There should be no semicolon after the second "WriteLn"
b. There is no error.
c. There should be no semicolon after the "end"
d. There should be no semicolon after the first WriteLn
e. There should be a colon between "inning" and ">"
18. In programing, when your program compiles and runs, but does
not implement the algorithm that you meant it to, you have
(one or more) __________ errors.
19. In Pascal, "initializing" a variable means
a. declaring the type of a variable
b. providing the variable with an initial value
c. defining the procedures that can use the variable
20. In a Pascal program, what will be the value of the variable
"ServiceOn" immediately after executing the following code?
____________
Program Waterservice;
var gallons, maxgallons:real; ServiceOn: boolean;
.
.
.
maxgallons :=10000;
gallons:= 11500;
if (gallons >= maxgallons) then ServiceOn:=false
else ServiceOn=true;"
.
.
.
21. In Pascal, what is the error in the following procedure
declaration?
Procedure End (key : char); {Lets user know that the keyboard}
{input has ended}
begin
if key = 'q' the Writeln ('You have finished entering data')
end; { of procedure}"
a. There is a missing semicolon after the word "begin"
b. You cannot use an "if" statement in a Procedure
c. The "if" statement is missing the "else"
d. End is a reserved word in Pascal, and cannot be the
name of a procedure
22. In Pascal, if you want the variable called "batting_average"
to assume values to parts in one thousand (e.g. 0.409) then
it should be declared as type ________.
23. In Pascal, the declaration of a variable tells the compiler
the variable's
a. name and initial value
b. type and actual value
c. name only
d. name and type
24. In Pascal, if you want the variable called "won" to be
either true or false, it should be declared as type
___________.
25. If the variables Sum, A, B, and C are all boolean, and if
the values for them are A:=True, B:=False, C:=True, what is
the value of Sum after the following statement?
______________
Sum:=(A and B and C) or ((A and (not B) and (not C))
or (((not A) and B and (not C)) or ((not A) and (not B) and C))):
26. Timesharing made good economic and business sense in the
1960's and 1970's but is not as attractive today, because
a. time sharing requires communications networks, and
these are now too expensive
b. today's workers are not good at sharing
c. the computing resource -- the CPU -- is no longer a
very expensive device
d. None of the above.
27. In a Pascal program, with buyflag declared boolean, and price,
bluebookprice, and maxprice declared real, and for price,
bluebookprice and maxprice having values respectively 3500, 3300,
and 4000, what will be the value of buyflag after the following
code is executed? ______________
buyflag := TRUE;
If (price > bluebookprice) OR (price > maxprice)
then buyflag := FALSE;
28. In Pascal programming, stepwise refinement is implemented by
programming in manageable units called _________________
29. In Pascal, the construction "If ... then ... else" is
considered to be
a. multiple statements
b. five statements
c. three statements
d. a single statement
e. two statements
30. In Pascal, the main program must be enclosed by a _________
and an __________.
31. In Pascal, the characteristic(s) of the for loop that
distinguish it from either the repeat loop or the while loop
is (are)
i the "for" loop tests at the beginning of the loop
ii the "for" loop automatically increments the counter variable
iii the "for" loop allows the programmer to directly specify the
number of times the loop is to be executed.
iv the test portion of the "for" can contain either AND or OR,
but not both
a. i and ii
b. ii and iv
c. ii only
d. ii and iii
e. i and iii
Part 2: Points as marked:
32. Two components of a von Neuman computer are "input" and "output".
Name the other three:
____________________________________ (2 Points)
____________________________________ (2 Points)
____________________________________ (2 Points)
33. (4 points) What are the four major parts (in proper order) of a
Pascal program?
____________________________________
____________________________________
____________________________________
____________________________________
34. A spreadsheet has entries in each cell from A1 through H7, and is
(partially) shown below:
A B C D E F G H
1 Batch Wafer Rejects Rejects Rejects Total Total Yield
2 Number Starts Step 1 Step 2 Step 3 Rejects Good
3 113 942 176 99 7
4 117 963 189 85 3
5 118 922 192 77 4
6 121 900 203 93 4
7 Totals
The following list gives the contents of the input line when the
cursor is on the corresponding cell. Provide (calculate) the
corresponding cell value
E7 @SUM(E3..E6) __________ (2 points)
F6 +C6+D6+E6 __________ (2 points)
G6 +B6-F6 __________ (2 points)
H6 +(B6-F6)/B6 __________ (2 points)
G5 'B5-@SUM(C5..F5) __________ (2 points)
35. How many times will the following loops execute? Assume count is
an integer)
a) for count := 0 to 6 do (2 points)
writeln('hello');
b) count := 0; (2 points)
while count >= 0 do
begin
count := count - 2;
writeln('hello');
end;
c) count := 1; (2 points)
repeat
DrawCircle(count,count+5);
count := count+1;
until count >= 3;
d) count := 0; (2 points)
while count < 5 do
begin
DrawCircle(count, count+1);
count := count + 1;
end;
e) count :=0; (2 points)
repeat
begin
DrawCircle(count, count+1);
count := count - 1;
end;
until count < 0;
36. (8 points) For the Pascal statement:
D := (A OR B) AND (B OR C) AND (C OR A);
which is equivalent to the logic circuit shown:
Complete the truth table for this statement / circuit
A B C D
0 0 0
0 0 1
0 1 0
0 1
1