Deck 7: Modularity Using Functions: Part II
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/49
Play
Full screen (f)
Deck 7: Modularity Using Functions: Part II
1
C functions are constructed to be independent modules.
True
2
Variables created inside a function are available only to other functions in the same C file.
False
3
Global variables are only meaningful when used in expressions or statements inside the function that declares them.
False
4
The same variable name cannot be declared and used in more than one function.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
5
Global variables can be used by all functions in a program that are physically placed after the global variable declaration.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
6
While a function is executing, only the storage area for the variables and parameters created by this function are automatically accessed.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
7
The scope of a variable influences or restricts the data type of the variable.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
8
The scoping rules for symbolic constants and function prototypes are the same as those for variables.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
9
Except for symbolic constants and function prototypes, local variables should almost never be used.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
10
Using global variables except in very restricted and well-defined situations is a sign of extremely bad programming.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
11
The scope of a variable can be thought of as the space within the program where the variable is valid.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
12
Storage for automatic local variables is automatically reserved (that is, created) before the program begins its execution.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
13
As long as a function has not returned control to its calling function, all automatic variables local to the function are "alive"; that is, storage for the variables is available.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
14
Once created, local static variables remain in existence for the life of the program.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
15
The initialization of static variables (both local and global) is done only once, when the
program is first compiled.
program is first compiled.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
16
Unlike automatic variables that can be initialized by either constants or expressions using both constants and previously initialized variables, static variables can only be initialized using constants or constant expressions.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
17
You can take the address of a register variable using the address operator &.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
18
Initialization within an extern declaration statement is not allowed and causes a compilation error.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
19
The scope of a global static variable can be extended beyond the file in which it is declared.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
20
Passing an address is referred to as a function pass by reference, because the called function can reference, or access, the variable using the passed address.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
21
When using a pointer variable, the value that is obtained is always found by first going to the pointer for an address; this is called indirect addressing.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
22
The default in C is to make calls by reference to limit a called function's ability to alter variables in the calling function.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
23
When the values of two variables are affected in a function, the function cannot be written as a call by value function.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
24
Pointers can be used to change constants.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
25
Self-referential functions are also called recursive functions.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
26
A memory stack is simply an area of memory used for rapidly storing and retrieving data.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
27
Some (but not all) recursive functions can be written in a nonrecursive manner using an iterative solution.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
28
A variable with a ____ scope is simply one that has had storage locations set aside for it by a declaration statement made within a function body.
A)function
B)module
C)local
D)global
A)function
B)module
C)local
D)global
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
29
The variable secnum is ____.
Int main()
{
Int secnum;
) . .
}
A)local to main()
B)global to main()
C)local to the program
D)global to the program
Int main()
{
Int secnum;
) . .
}
A)local to main()
B)global to main()
C)local to the program
D)global to the program
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
30
Coding a function prototype as ____ makes sense when the function is used by a number of other functions in a source code file.
A)private
B)global
C)local
D)void
A)private
B)global
C)local
D)void
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
31
____ variables allow the programmer to "jump around" the normal safeguards provided by functions.
A)Global
B)Local
C)Static
D)void
A)Global
B)Local
C)Static
D)void
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
32
The ____ of a variable defines the location within a program where that variable can be used.
A)storage class
B)time dimension
C)scope
D)data type
A)storage class
B)time dimension
C)scope
D)data type
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
33
The four available storage classes are called auto, static, extern, and ____.
A)stack
B)intern
C)void
D)register
A)stack
B)intern
C)void
D)register
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
34
____ can only be members of the auto, static, or register storage classes.
A)Constants
B)int variables
C)Local variables
D)Global variables
A)Constants
B)int variables
C)Local variables
D)Global variables
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
35
If no class description is included in the declaration statement of a local variable, the variable is automatically assigned to the ____ class.
A)auto
B)static
C)extern
D)register
A)auto
B)static
C)extern
D)register
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
36
When the function returns control to its calling function, its ____ variables "die".
A)local static
B)extern
C)local extern
D)local auto
A)local static
B)extern
C)local extern
D)local auto
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
37
In ____ initialization, initialization occurs each time the declaration statement is encountered.
A)dynamic
B)static
C)compile-time
D)run-time
A)dynamic
B)static
C)compile-time
D)run-time
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
38
____ variables have the same time duration as automatic variables.
A)Static
B)Register
C)Extern
D)Global
A)Static
B)Register
C)Extern
D)Global
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
39
____ is a high-speed storage area physically located in the computer's processing unit.
A)A reserved variable
B)RAM
C)A register
D)A stack
A)A reserved variable
B)RAM
C)A register
D)A stack
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
40
____ variables may be declared as members of the static or extern storage class.
A)Local
B)Global
C)Automatic
D)Register
A)Local
B)Global
C)Automatic
D)Register
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
41
The purpose of the ____ storage class is to extend the scope of a global variable declared in one source code file into another source code file.
A)auto
B)static
C)extern
D)register
A)auto
B)static
C)extern
D)register
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
42
A declaration statement that specifically contains the word ____ is different from every other declaration statement in that it does not cause the creation of a new variable by reserving new storage for the variable.
A)auto
B)static
C)extern
D)register
A)auto
B)static
C)extern
D)register
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
43
A variable that can store an address is known as a(n) ____ variable.
A)register
B)pointer
C)static
D)extern
A)register
B)pointer
C)static
D)extern
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
44
To use a stored address, C provides us with an indirection operator, ____.
A)%
B)^
C)&
D)*
A)%
B)^
C)&
D)*
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
45
If numAddr is a pointer, ____ means the variable whose address is stored in numAddr.
A)*numAddr
B)numAddr*
C)&numAddr
D)*&numAddr
A)*numAddr
B)numAddr*
C)&numAddr
D)*&numAddr
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
46
The declaration statement ____ declares milesAddr to be a pointer variable that can store the address of (that is, will point to) an integer variable.
A)int milesAddr&;
B)int milesAddr*;
C)int *milesAddr;
D)int &milesAddr;
A)int milesAddr&;
B)int milesAddr*;
C)int *milesAddr;
D)int &milesAddr;
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
47
Functions that call themselves are referred to as ____ functions.
A)nested
B)recursive
C)loop-back
D)rolling
A)nested
B)recursive
C)loop-back
D)rolling
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
48
When a function invokes itself, the process is called ____ recursion.
A) direct
B) mutual
C) self-referential
D) indirect
A) direct
B) mutual
C) self-referential
D) indirect
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
49
A function can invoke a second function, which in turn invokes the first function; this type of recursion is referred to as ____ recursion.
A) direct
B) mutual
C) self-referential
D) tail
A) direct
B) mutual
C) self-referential
D) tail
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck