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: @ 3.136.154.103

1. Given the following declaration:

int Values[25];

Which expression below is equivalent to: Values?

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

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

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. 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. What will be the output of the following FOR loop?

for(i=0 ; i<5 ; i++)
     {
     if (i==2) continue;
     printf("%d", i);
     }

a) 1 2 3 4 5
b) 0 1 2 3 4
c) 0 1 3 4
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 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

8. Given the declarations:

char szData[64];
int i;

i=314;

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

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

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

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

11. Which of these lists the fundamental data types of the C language in correct order of precision?

a) INT - CHAR - FLOAT - LONG INT - DOUBLE
b) INT - CHAR - DOUBLE - LONG INT - FLOAT
c) FLOAT - CHAR - INT - LONG INT - DOUBLE
d) CHAR - INT - LONG INT - FLOAT - DOUBLE
e) None of the above

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

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

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

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

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

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

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

switch (a)
     {
     case 1: printf("TV is on.");

     case 2: printf("Stereo is on.");
         break;

     case 3: printf("Room lights dimmed.");
         break;

     default: printf("Say what?");
         break;
     }

a) TV is on.
b) TV is on. Stereo is on.
c) Room lights dimmed.
d) Say what?

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

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

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

NOTE

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!