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

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

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

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. When do C functions need to be prototyped in single-source-file projects?

a) Prototyping is always optional in C as long as a single file contains all the source code.
b) When functions are called before they are defined (i.e., function 'below' use in listing.)
c) Prototyping is always required, regardless of where the functions are used.
d) None of the above

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

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

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

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

11. What will the output of the following code be?

double Zeta; // Holds ratio of alpha/w(nat)

Zeta = 0.707107; // Less than critically damped system
printf("Damping ratio = %10.1lf\n", Zeta );

a) Damping ratio = 0.707107
b) Damping ratio = 0.707
c) Damping ratio = 0.7
d) None of these

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

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

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

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

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

17. The instructions typed by a programmer that will be compiled and executed by the computer are called:

a) Source code
b) Machine code
c) Object code
d) None of the above

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

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

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!