Return to Topic Menu | Computer Science Main Page | MathBits.com  | Terms of Use | Resource CD
 

Multiple Choice C++ Quiz
 Library Functions

 

Directions:  Choose the best answer.  Use the button at the bottom
to check your answers.


1.  When using a built-in function, you must
     [a] include the function's prototype.
     [b] include the proper header file.
     [c] include the function's definition.
     [d] specify the length of the library function.
 

2.  The library function isalpha( ) requires the header file

     [a] <ctype.h>
     [b] <math.h>
     [c] <time.h>
     [d] <stdlib.h>

3.  The built-in library function isalnum( ) is testing to determine if the argument is

     [a] one of "all" numbers available from the keyboard.
     [b] an alphabet character.
     [c] an ASCII character.
     [d] an alphanumeric.

4.  When using atoi( ) with an apstring variable,

     [a] you must convert the apstring to a standard string by using .c_str( ).
     [b] all numbers within the string will be converted to integers.
     [c] all characters within the string will be converted to ASCII equivalents.
     [d] all alphabetic characters within the string will be counted.

5.  The built-in library function ceil(x) requires the header file

     [a] <ctype.h>
     [b] <math.h>
     [c] <stdlib.h>
     [d] <time.h>

6.  To raise any number to a power, use

     [a] the exponent symbol ^.
     [b] the built-in library function pow(x,y).
     [c] the built-in library function pow10(x).
     [d] concatenation.

7.  time_t is

     [a] a variable used to hold a number from the computer's internal clock.
     [b] a data type
     [c] a built-in library function which will return a value from the internal clock.
     [d] a header file.

8.  The function time(NULL) returns the number of seconds elapsed since 00:00:00 hours

     [a] January 1, 1900.
     [b] January 1, 1950.
     [c] January 1, 1970.
     [d] January 1, 1990.

9.  The rand( ) built-in library function

     [a] is a true random number generator.
     [b] returns positive double values.
     [c] is a pseudo-random number generator.
     [d] returns a different sequence of values each time it is run.

10.  In the formula used for generating random numbers within a specific range
                   (int number = a + rand( ) % n;), the n represents

     [a] the first value in the range of numbers.
     [b] the last value in the range of numbers.
     [c] the number of terms in the range of numbers.
     [d] the number of guesses the user will be allowed.

11.  To create random numbers between 28 and 52 inclusive, use the formula

     [a] int number - 28 + rand( ) % 52;
     [b] int value = 1 + rand( ) % 28;
     [c] int random_value = 28 + rand( ) % 24;
     [d] int rand_num = 28 + rand( ) % 25;

12.  The built-in library function srand( ) is

     [a] used to set the starting seed for generating random values.
     [b] used to generate random values.
     [c] used to generate "special" random numbers.
     [d] used to force a duplication of the random sequence pattern.

13.  Which of the following lines of code will ensure that a different random sequence will occur with each run of the program in the Visual C++ programming language?

     [a] int number = 2 + rand( ) % 5;
     [b] randomize( );
     [c] randomize(timer);
     [d] srand(time(NULL));

14.  The purpose of the code answer = toupper(ans); is to ensure that

     [a] answer will be rounded to the next larger integer.
     [b] the first letter in answer will be a capital letter.
     [c] answer will contain all capital letters.
     [d] answer will contain no numeric values.

15.  Which of the following is not a member function of the apstring class?

     [a] length( )
     [b] substr(x,y)
     [c] atof(s)
     [d] c_str( )

 

Return to Topic Menu | Computer Science Main Page | MathBits.com | Terms of Use | Resource CD