Assessment Test

Sample Questions

Fundamentals of Programming

XHTML code by Janeice Templeton

1. Which of the following is the first step in the computer problem-solving process?

Plan the algorithm.
Code the algorithm into a program.
Evaluate and modify the program.
Analyze the problem.

2. The value of 7 - 5 + 4 * 3 is

18
4
14
None of These

3. Which type of memory is volatile, i.e., it maintains data on a temporary basis?

RAM
ROM
CD
Floppy Drive
Hard Drive

4. Which component of a computer fetches and executes program instructions?

CPU
Memory
ALU
Hard disk

5. A Selection control structure:

repeats a number of program steps multiple times
chooses one of several alternative sets of instructions to be executed
executes a series of instructions in order
selects the appropriate I/O device for output

6. A variable which is accessible only within the function where it is declared is a:

global variable
local variable
constant variable
nonlocal variable

7. How many times will the following looping structure be executed?

int count = 1;
do
   {
     count = count + 1;
   }
     while (count < 10);

20 times
10 times
9 times
none of the above

8. Which of the following is not a logical operator?

&&
||
!
>

9. The following coding could be used to initialize data in a:

for (int i=0; i < 5; i++)
   f[i] = 0;

one element array named f
one element array named i
five element array named f
five element array named i

10. The expression P || Q, is true, if:

P is true and Q is false
Q is true and P is false
P is true and Q is true
All of the above

11. When parameters are passed between the calling function and the called function, formal and actual parameters are matched by:

their data types
their relative position in the formal and actual parameter lists
their names
whether they are inputs to or outputs from the function

12. An array is a(n):

class
Simple data type
Data structure containing multiple values
Iterative structure

13. Given the following declaration statement:

double prices[20];
the valid subscript range for prices would be:

0 to 20
1 to 20
1 to 19
0 to 19

14. What does the following C++ statement do?

if (A > B)
   if (B > C)
     C = 1;
   else
     C = 2;

Assigns a value to C only when A > B
Assigns a value to C only when A > B and B > C
Assigns a value to C if C >= A regardless of the values of A and B
None of the above

15. Which of the following statements is not true concerning an array?

All array elements must be of the same data type
An array element can be treated like a variable of its element data type
An array can be passed as a parameter to a function
An array is an unstructured data type

16. Given the following C++ code:
int count = 0, sum = 0;
while (count < 5)
{
   sum = sum + count;
   count ++;
}

The contents of sum after this code has executed will be:

0
5
10
15

17. Which type of loop is the following (assume variables are type double):

score = getScore();
while (score != -1)
{
   sum = sum + score;
   score = getScore();
}

Sentinel controlled
Flag controlled
Count controlled
None of the above

18. A function can return at most:

0 values
1 value
2 values
any number of values

Valid XHTML 1.0 Strict