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. 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

2. Given the following declaration:

char szName[24];

How many characters can be in the array (excluding the terminator)?

a) 24
b) 25
c) 23
d) None of these

3. 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

4. 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

5. According to the way "MyFunct" is being used below, what is its prototype?

int x,y;
float z;
//Program logic to fill x and y with data here

z=MyFunct(x, y);

a) void MyFunct(int, int);
b) double MyFunct(double, int);
c) float MyFunct(int, int);
d) None of these

6. 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

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

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

8. 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

9. 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

10. 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

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 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

13. 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

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

a) '\n'
b) '\0'
c) '\7'
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 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

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 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

19. 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

20. 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.


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!