CSIS 123 Practice Test II

Instructions: There are 20 questions on this test. It is written in a style very similar to the REAL Exam #2. Choose the best answer from among those given. Click the GRADE button on the bottom of the form when you want the exam graded.

Note: You can practice this test as many times as you desire; the system will cook you up a fresh batch of questions each time you access this page.

Your Name: @

1. What library function should be used to compare character string arrays?

a) strcat
b) strlen
c) strcmp
d) None of these

2. What is wrong with the following code?

int nValue = 25;
float* fAddr;

fAddr = &nValue;
*fAddr = *fAddr + 1;

a) It is illegal to use the expression *fAddr on the left side of an equals sign.
b) The pointer "fAddr" has not been loaded with the address of an object.
c) The pointer "fAddr" is of the wrong type (float*).
d) None of these

3. Which of these would be BEST to do before using a pointer to access memory?

a) Make sure sufficient memory exists to use the pointer.
b) Check to see if your C compiler supports pointers.
c) Make sure the pointer address is valid
d) None of these

4. Given the following declaration:

int Values[4]={1,2,3,4};

What value will be returned if the expression "*Values" is evaluated?

a) 2
b) 1
c) &Values[0]
d) 4
e) None of these

5. The data being manipulated by a program is also known as:

a) The objects
b) The algorithm
c) The flow
d) None of the above

6. What information must be passed to the STRCPY() library routine?

a) The length of each string, and the address of each string.
b) The address of each string.
c) The length of one of the strings.
d) None of these

7. What is meant by the term "dereferencing?"

a) Finding the master inertial frame of reference
b) Accessing the memory contents addressed by a pointer
c) Finding the memory address of a value
d) None of the above

8. Given the following declaration:

int Values[25];

Which expression below is equivalent to: &Values[0]?

a) Values[0]
b) Values[-1]
c) Values
d) None of these

9. What is the meaning of the following declaration?

float* pVar;

a) pVar is a pointer to data of type FLOAT
b) pVar is a floating point variable
c) pVar is meant to have an initial value of zero
d) None of these

10. What is wrong with the following code?

char szPassword[24];
gets(szPassword); // Get user password

if ( szPassword == "Joshua" ) printf("Welcome!");

a) The comparison method (==) will not work with strings.
b) GETS() does not input character strings.
c) The array declaration is invalid.
d) None of these

11. If A=2 upon entry into the code below, what will be output?

switch (a)
     case 1: printf("Unlocking door.");

     case 2: printf("Checking back door.");

     case 3: printf("Locking door.");

     default: printf("Unknown command.");

a) Checking back door
b) Unlocking door
c) Locking door
d) Unknown command

12. What character code is used to end all strings in C?

a) '\n'
b) '\0'
c) '\7'
d) None of these

13. Given the following declaration:

int Values[4]={1,2,3,4};

What value will be returned if the expression "*(Values+2)" is evaluated?

a) 2
b) 1
c) 3
d) Insufficient information given to solve problem.

14. Given the declarations:

char szData[64];
int i;


Supposed that we wish to place a text message into szData that shows the value in variable i. Which of the statements below would accomplish this?

a) strcpy( szData , "i = %d", i);
b) sprintf( szData , "i = %d" , i );
c) strcat( szData , i , "i = %d" );
d) None of these

15. What is the data type of the following expression?

"The quick brown fox jumped over the lazy dog."

a) int*
b) double*
c) float*
d) char*
e) None of the above

16. What is one dangerous situation that can occur when programming character string input in C?

a) Using up excessive amounts of memory.
b) Taking up too much CPU time requirements, which can slow down the disk system.
c) Having insufficient space in an array to hold all the user's input.
d) None of these

17. In order to solve a problem using a programming language, what must be done first?

a) Determine an algorithm that solves the problem
b) Write computer source code instructions
c) Define the problem
d) None of the above

18. What is special about the NULL pointer value?

a) The NULL pointer automatically dereferences the target object.
b) Arrays can only be accessed if a NULL pointer is used.
c) The NULL pointer is obtained when a disk I/O error occurs.
d) None of these

19. Which declaration below would be correct to make "pVar" a pointer to int type?

a) int pVar;
b) int* pVar;
c) int &pVar;
d) None of these

20. What is something that can not be done with a VOID pointer?

a) Dereferencing
b) Assignment of pointer value
c) Type-casting pointer contents to another type
d) None of these


When you take Exam #2, you will also have to write some code. Make sure you can write functions given a behaviorial specification, properly call functions given a prototype, and work with pointers and arrays.

Press GRADE EXAM button to see how you did!

Grade Exam!