Deck 6: Modularity Using Functions: Part I

Full screen (f)
exit full mode
Question
Terms used as synonyms for arguments are actual arguments and actual parameters.
Use Space or
up arrow
down arrow
to flip the card.
Question
Pass by value is also referred to as pass by reference.
Question
Parameters are sometimes referred to as actual parameters.
Question
Parameters are sometimes referred to as formal arguments.
Question
The function declarator is sometimes referred to as function prototype.
Question
Random numbers are a series of numbers whose order cannot be predicted.
Question
Pseudorandom numbers are numbers which are not really random, but are sufficiently random for the task at hand.
Question
In earlier versions of C, function prototypes were required.
Question
In earlier versions of C, if a function header line omitted a return data type, the return value was, by default, implicitly declared as being of type void.
Question
In C, it is permitted to nest one function inside another.
Question
Each C function is a separate and independent entity with its own parameters and variables.
Question
When you write a function, you are formally creating a function definition.
Question
The function's prototype, along with pre- and postcondition comments should provide a programmer with all the information necessary to call the function successfully.
Question
Postconditions are any set of conditions required by a function to be true if it is to operate correctly.
Question
All preprocessor directives, variables, named constants, and functions, except main(), must be either declared or defined before they can be used.
Question
A function returning a value must specify, in its header line, the data type of the value that will be returned.
Question
The parentheses in a return statement are required.
Question
Failure to exactly match the return value with the function's declared data type can lead to undesired results because the return value is always converted to the data type declared in the function's header line.
Question
The value of an expression can be explicitly converted into another type using the cast operator.
Question
A basic rule of testing states that each function should only be tested in a program in which all other functions are known to be correct.
Question
The standard C library consists of 5 header files.
Question
Placing the appropriate #include statement at the bottom of the program ensures proper access to the library functions whose prototypes are contained in the header file.
Question
The rand() function produces a series of random numbers in the range 0 < rand() < RAND_MAX, where the constant RAND_MAX is a compiler-dependent symbolic constant that is defined in the stdlib.h header file.
Question
Many C compilers have a randomize() routine that is defined using the srand() function.
Question
The getcharacter() function can be used for single character input.
Question
There is no C string data type.
Question
A function that is called or summoned into action by its reference in another function is a ____.

A)function prototype
B)called function
C)calling function
D)function declarator
Question
A function that calls another function is referred to as the ____.

A)function prototype
B)called function
C)calling function
D)function declarator
Question
A ____ declares the function to the compiler-it tells the compiler the name of the function, the data type of the value that the function will return (the keyword void indicates that the function will not be returning any value), and the data types of each argument that the function expects to receive when it is called.

A)function prototype
B)function header
C)function body
D)function declarator
Question
When a function simply receives copies of the values of the arguments and must determine where to store these values before it does anything else, this is known as a ____.

A)pass by value
B)pass by reference
C)stub
D)function declarator
Question
The purpose of a ____ is to identify the data type of the value returned by the function, if any, provide the function with a name, and specify the number, order, and type of values expected by the function.

A)function declarator
B)prototype
C)function body
D)function header
Question
The purpose of a ____ is to operate on the passed data and return, at most, one value directly back to the calling function.

A)function declarator
B)prototype
C)function body
D)function header
Question
The argument names in the header line of a function are known as ____.

A)arguments
B)parameters
C)actual arguments
D)actual parameters
Question
The portion of the function header that contains the function name and parameters is known as a ____.

A)function body
B)prototype
C)function declarator
D)stub
Question
The method for adjusting the random numbers produced by a random-number generator to reside within a specified range is called ____.

A)scaling
B)stubbing
C)prototyping
D)converting
Question
___ is an example of a function header line.

A)float roi(int, double);
B)float roi( int yrs, double rate);
C)printf("%f", roi(3, amt));
D)float roi( int yrs, double rate)
Question
___ is an example of a function prototype.

A)float roi(int, double);
B)roi(3, amt);
C)printf("%f", roi(3, amt));
D)float roi( int yrs, double rate)
Question
___ is an example of a calling statement.

A)float roi(int, double);
B)float roi( int yrs, double rate);
C)printf("%f", roi(3, amt));
D)float roi( int yrs, double rate)
Question
____ is a prototype of a function that returns no value.

A)void funcA();
B)funcA();
C)int funcA();
D)null funcA();
Question
To return a value, a function must use a(n) ____ statement.

A)exit
B)throw
C)break
D)return
Question
The minimum requirement of a ____ is that it compile and link with its calling module.

A)function body
B)function prototype
C)stub function
D)function declarator
Question
___ is the correct way to include a header file in your program.

A)#include
B)#include header-file-name
C)#include ;
D)#include header-file-name;
Question
The function ____ returns the absolute value of its double-precision argument.

A)double ceil(double)
B)double fmod(double)
C)double fabs(double)
D)double abs(double)
Question
The function ____ returns the common logarithm of its argument.

A)double exp(double)
B)double log(double)
C)double log10(double)
D)double fmod(double)
Question
The function ____ returns the natural logarithm of its argument.

A)double exp(double)
B)double log(double)
C)double log10(double)
D)double fmod(double)
Question
All C compilers provide ____ function(s) for creating random numbers, defined in the stdlib.h header file.

A)one
B)two
C)three
D)four
Question
The ____ function can be used to generate a random number in C.

A)rand()
B)srand()
C)random()
D)rnd()
Question
____ reads the computer's internal clock time, in seconds.

A)stime()
B)time(SECONDS)
C)time()
D)time(NULL)
Question
Scaling a random number as an integer value between 1 and N is accomplished using the expression ____.

A)1 + (int)rand() / N
B)1 + (int)rand() % N
C)(int)rand() / N
D)(int)rand() % N
Question
The function ____ returns a non-0 number if the argument is a letter or a digit; otherwise it returns a 0.

A) int isalnum(int)
B) int isalpha(int)
C) int isdigit(int)
D) int isxdigit(int)
Question
The function ____ converts an ASCII string to an integer.

A) string itoa(int)
B) double atof(string)
C) int atoi(string)
D) int toupper(int)
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/51
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 6: Modularity Using Functions: Part I
1
Terms used as synonyms for arguments are actual arguments and actual parameters.
True
2
Pass by value is also referred to as pass by reference.
False
3
Parameters are sometimes referred to as actual parameters.
False
4
Parameters are sometimes referred to as formal arguments.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
5
The function declarator is sometimes referred to as function prototype.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
6
Random numbers are a series of numbers whose order cannot be predicted.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
7
Pseudorandom numbers are numbers which are not really random, but are sufficiently random for the task at hand.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
8
In earlier versions of C, function prototypes were required.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
9
In earlier versions of C, if a function header line omitted a return data type, the return value was, by default, implicitly declared as being of type void.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
10
In C, it is permitted to nest one function inside another.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
11
Each C function is a separate and independent entity with its own parameters and variables.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
12
When you write a function, you are formally creating a function definition.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
13
The function's prototype, along with pre- and postcondition comments should provide a programmer with all the information necessary to call the function successfully.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
14
Postconditions are any set of conditions required by a function to be true if it is to operate correctly.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
15
All preprocessor directives, variables, named constants, and functions, except main(), must be either declared or defined before they can be used.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
16
A function returning a value must specify, in its header line, the data type of the value that will be returned.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
17
The parentheses in a return statement are required.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
18
Failure to exactly match the return value with the function's declared data type can lead to undesired results because the return value is always converted to the data type declared in the function's header line.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
19
The value of an expression can be explicitly converted into another type using the cast operator.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
20
A basic rule of testing states that each function should only be tested in a program in which all other functions are known to be correct.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
21
The standard C library consists of 5 header files.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
22
Placing the appropriate #include statement at the bottom of the program ensures proper access to the library functions whose prototypes are contained in the header file.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
23
The rand() function produces a series of random numbers in the range 0 < rand() < RAND_MAX, where the constant RAND_MAX is a compiler-dependent symbolic constant that is defined in the stdlib.h header file.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
24
Many C compilers have a randomize() routine that is defined using the srand() function.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
25
The getcharacter() function can be used for single character input.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
26
There is no C string data type.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
27
A function that is called or summoned into action by its reference in another function is a ____.

A)function prototype
B)called function
C)calling function
D)function declarator
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
28
A function that calls another function is referred to as the ____.

A)function prototype
B)called function
C)calling function
D)function declarator
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
29
A ____ declares the function to the compiler-it tells the compiler the name of the function, the data type of the value that the function will return (the keyword void indicates that the function will not be returning any value), and the data types of each argument that the function expects to receive when it is called.

A)function prototype
B)function header
C)function body
D)function declarator
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
30
When a function simply receives copies of the values of the arguments and must determine where to store these values before it does anything else, this is known as a ____.

A)pass by value
B)pass by reference
C)stub
D)function declarator
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
31
The purpose of a ____ is to identify the data type of the value returned by the function, if any, provide the function with a name, and specify the number, order, and type of values expected by the function.

A)function declarator
B)prototype
C)function body
D)function header
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
32
The purpose of a ____ is to operate on the passed data and return, at most, one value directly back to the calling function.

A)function declarator
B)prototype
C)function body
D)function header
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
33
The argument names in the header line of a function are known as ____.

A)arguments
B)parameters
C)actual arguments
D)actual parameters
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
34
The portion of the function header that contains the function name and parameters is known as a ____.

A)function body
B)prototype
C)function declarator
D)stub
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
35
The method for adjusting the random numbers produced by a random-number generator to reside within a specified range is called ____.

A)scaling
B)stubbing
C)prototyping
D)converting
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
36
___ is an example of a function header line.

A)float roi(int, double);
B)float roi( int yrs, double rate);
C)printf("%f", roi(3, amt));
D)float roi( int yrs, double rate)
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
37
___ is an example of a function prototype.

A)float roi(int, double);
B)roi(3, amt);
C)printf("%f", roi(3, amt));
D)float roi( int yrs, double rate)
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
38
___ is an example of a calling statement.

A)float roi(int, double);
B)float roi( int yrs, double rate);
C)printf("%f", roi(3, amt));
D)float roi( int yrs, double rate)
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
39
____ is a prototype of a function that returns no value.

A)void funcA();
B)funcA();
C)int funcA();
D)null funcA();
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
40
To return a value, a function must use a(n) ____ statement.

A)exit
B)throw
C)break
D)return
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
41
The minimum requirement of a ____ is that it compile and link with its calling module.

A)function body
B)function prototype
C)stub function
D)function declarator
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
42
___ is the correct way to include a header file in your program.

A)#include
B)#include header-file-name
C)#include ;
D)#include header-file-name;
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
43
The function ____ returns the absolute value of its double-precision argument.

A)double ceil(double)
B)double fmod(double)
C)double fabs(double)
D)double abs(double)
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
44
The function ____ returns the common logarithm of its argument.

A)double exp(double)
B)double log(double)
C)double log10(double)
D)double fmod(double)
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
45
The function ____ returns the natural logarithm of its argument.

A)double exp(double)
B)double log(double)
C)double log10(double)
D)double fmod(double)
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
46
All C compilers provide ____ function(s) for creating random numbers, defined in the stdlib.h header file.

A)one
B)two
C)three
D)four
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
47
The ____ function can be used to generate a random number in C.

A)rand()
B)srand()
C)random()
D)rnd()
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
48
____ reads the computer's internal clock time, in seconds.

A)stime()
B)time(SECONDS)
C)time()
D)time(NULL)
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
49
Scaling a random number as an integer value between 1 and N is accomplished using the expression ____.

A)1 + (int)rand() / N
B)1 + (int)rand() % N
C)(int)rand() / N
D)(int)rand() % N
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
50
The function ____ returns a non-0 number if the argument is a letter or a digit; otherwise it returns a 0.

A) int isalnum(int)
B) int isalpha(int)
C) int isdigit(int)
D) int isxdigit(int)
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
51
The function ____ converts an ASCII string to an integer.

A) string itoa(int)
B) double atof(string)
C) int atoi(string)
D) int toupper(int)
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 51 flashcards in this deck.