Deck 6: Functions

ملء الشاشة (f)
exit full mode
سؤال
This function causes a program to terminate, regardless of which function or control mechanism is executing.

A)terminate()
B)return()
C)continue()
D)exit()
E)None of these
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
________ functions may have the same name, as long as their parameter lists are different.

A)Only two
B)Two or more
C)Zero
D)Un-prototyped
E)None of these
سؤال
This is a statement that causes a function to execute.

A)for loop
B)do-while loop
C)function prototype
D)function call
E)None of these
سؤال
The value in this type of local variable persists between function calls.

A)global
B)internal
C)static
D)dynamic
E)None of these
سؤال
A function ________ contains the statements that make up the function.

A)definition
B)prototype
C)call
D)expression
E)parameter list
سؤال
In a function header, you must furnish:

A)data type(s)of the parameters
B)data type of the return value
C)the name of function
D)names of parameter variables
E)All of these
سؤال
It is a good programming practice to ________ your functions by writing comments that describe what they do.

A)execute
B)document
C)eliminate
D)prototype
E)None of these
سؤال
A function ________ eliminates the need to place a function definition before all calls to the function.

A)header
B)prototype
C)argument
D)parameter
E)None of these
سؤال
A function can have zero to many parameters, and it can return this many values.

A)zero to many
B)no
C)only one
D)a maximum of ten
E)None of these
سؤال
A ________ variable is declared outside all functions.

A)local
B)global
C)floating-point
D)counter
E)None of these
سؤال
When used as parameters, these types of variables allow a function to access the parameter's original argument.

A)reference
B)floating-point
C)counter
D)undeclared
E)None of these
سؤال
Given the following function definition: <strong>Given the following function definition:   What is the output of the following code fragment that invokes calc?  </strong> A)1 2 3 B)1 6 3 C)3 6 3 D)1 14 9 E)None of these <div style=padding-top: 35px>
What is the output of the following code fragment that invokes calc?
<strong>Given the following function definition:   What is the output of the following code fragment that invokes calc?  </strong> A)1 2 3 B)1 6 3 C)3 6 3 D)1 14 9 E)None of these <div style=padding-top: 35px>

A)1 2 3
B)1 6 3
C)3 6 3
D)1 14 9
E)None of these
سؤال
A function is executed when it is:

A)defined
B)prototyped
C)declared
D)called
E)None of these
سؤال
Which of the following statements about global variables is true?

A)A global variable is accessible only to the main function.
B)A global variable is declared in the highest-level block in which it is used.
C)A global variable can have the same name as a variable that is declared locally within a function.
D)If a function contains a local variable with the same name as a global variable, the global variable's name takes precedence within the function.
E)All of these are true.
سؤال
This type of variable is defined inside a function and is not accessible outside the function.

A)global
B)reference
C)local
D)counter
E)None of these
سؤال
These types of arguments are passed to parameters automatically if no argument is provided in the function call.

A)Local
B)Default
C)Global
D)Relational
E)None of these
سؤال
A(n)________ is information that is passed to a function, and a(n)________ is information that is received by a function.

A)function call, function header
B)parameter, argument
C)argument, parameter
D)prototype, header
E)None of these
سؤال
This is a collection of statements that performs a specific task.

A)infinite loop
B)variable
C)constant
D)function
E)None of these
سؤال
Functions are ideal for use in menu-driven programs. When a user selects a menu item, the program can ________ the appropriate function.

A)call
B)prototype
C)define
D)declare
E)None of these
سؤال
This statement causes a function to end.

A)end
B)terminate
C)return
D)release
E)None of these
سؤال
A local variable and a global variable may not have the same name within the same program.
سؤال
Look at the following function prototype.
<strong>Look at the following function prototype.   What is the data type of the function's return value?</strong> A)int B)double C)void D)Can't tell from the prototype <div style=padding-top: 35px>
What is the data type of the function's return value?

A)int
B)double
C)void
D)Can't tell from the prototype
سؤال
Look at the following function prototype.
<strong>Look at the following function prototype.   How many parameter variables does this function have?</strong> A)1 B)2 C)3 D)Can't tell from the prototype <div style=padding-top: 35px>
How many parameter variables does this function have?

A)1
B)2
C)3
D)Can't tell from the prototype
سؤال
What is the output of the following program?
<strong>What is the output of the following program?  </strong> A)5 B)2 C)7 D)getValue(x) <div style=padding-top: 35px>

A)5
B)2
C)7
D)"getValue(x)"
سؤال
Here is the header for a function named computeValue: void computeValue(int value)
Which of the following is a valid call to the function?

A)computeValue(10)
B)computeValue(10);
C)void computeValue(10);
D)void computeValue(int x);
سؤال
If a function does not have a prototype, default arguments may be specified in the function ________.

A)call
B)header
C)execution
D)return type
E)None of these
سؤال
What is the output of the following program?
<strong>What is the output of the following program?  </strong> A)   B)   C)   D)   <div style=padding-top: 35px>

A) <strong>What is the output of the following program?  </strong> A)   B)   C)   D)   <div style=padding-top: 35px>
B) <strong>What is the output of the following program?  </strong> A)   B)   C)   D)   <div style=padding-top: 35px>
C) <strong>What is the output of the following program?  </strong> A)   B)   C)   D)   <div style=padding-top: 35px>
D) <strong>What is the output of the following program?  </strong> A)   B)   C)   D)   <div style=padding-top: 35px>
سؤال
When a function is called, flow of control moves to the function's prototype.
سؤال
What is the output of the following program?
<strong>What is the output of the following program?  </strong> A) 2 2 B) 4 2 C) 2 4 D) 4 4 <div style=padding-top: 35px>

A)
2
2
B)
4
2
C)
2
4
D)
4
4
سؤال
Which line in the following program contains the header for the showDub function?
<strong>Which line in the following program contains the header for the showDub function?  </strong> A)4 B)6 C)10 D)15 <div style=padding-top: 35px>

A)4
B)6
C)10
D)15
سؤال
Look at the following function prototype.
<strong>Look at the following function prototype.   What is the data type of the function's parameter variable?</strong> A)int B)double C)void D)Can't tell from the prototype <div style=padding-top: 35px>
What is the data type of the function's parameter variable?

A)int
B)double
C)void
D)Can't tell from the prototype
سؤال
What is the output of the following program?
<strong>What is the output of the following program?  </strong> A)   B)   C)   D)   <div style=padding-top: 35px>

A) <strong>What is the output of the following program?  </strong> A)   B)   C)   D)   <div style=padding-top: 35px>
B) <strong>What is the output of the following program?  </strong> A)   B)   C)   D)   <div style=padding-top: 35px>
C) <strong>What is the output of the following program?  </strong> A)   B)   C)   D)   <div style=padding-top: 35px>
D) <strong>What is the output of the following program?  </strong> A)   B)   C)   D)   <div style=padding-top: 35px>
سؤال
Which line in the following program contains a call to the showDub function?
<strong>Which line in the following program contains a call to the showDub function?  </strong> A)4 B)6 C)10 D)15 <div style=padding-top: 35px>

A)4
B)6
C)10
D)15
سؤال
The value in a ________ variable persists between function calls.

A)dynamic
B)local
C)counter
D)static local
سؤال
A parameter is a special-purpose variable that is declared inside the parentheses of a function definition.
سؤال
This is a dummy function that is called instead of the actual function it represents.

A)main function
B)stub
C)driver
D)overloaded function
سؤال
EXIT_FAILURE and ________ are named constants that may be used to indicate success or failure when the exit()function is called.

A)EXIT_TERMINATE
B)EXIT_SUCCESS
C)EXIT_OK
D)RETURN_OK
E)None of these
سؤال
Which line in the following program contains the prototype for the showDub function?
<strong>Which line in the following program contains the prototype for the showDub function?  </strong> A)4 B)6 C)10 D)15 <div style=padding-top: 35px>

A)4
B)6
C)10
D)15
سؤال
A ________ argument is passed to a parameter when the actual argument is left out of the function call.

A)false
B)true
C)null
D)default
E)None of these
سؤال
If a function is called more than once in a program, the values stored in the function's local variables do not ________ between function calls.

A)persist
B)execute
C)communicate
D)change
E)None of these
سؤال
You must furnish an argument with a function call.
سؤال
It is not considered good programming practice to declare all of your variables globally.
سؤال
You may use the exit()function to terminate a program, regardless of which control mechanism is executing.
سؤال
A function's return data type must be the same as the function's parameter(s).
سؤال
A static variable that is defined within a function is initialized only once, the first time the function is called.
سؤال
It is possible for a function to have some parameters with default arguments and some without.
سؤال
One reason for using functions is to break programs into manageable units, or modules.
سؤال
Global variables are initialized to zero by default.
سؤال
Local variables are initialized to zero by default.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/49
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 6: Functions
1
This function causes a program to terminate, regardless of which function or control mechanism is executing.

A)terminate()
B)return()
C)continue()
D)exit()
E)None of these
exit()
2
________ functions may have the same name, as long as their parameter lists are different.

A)Only two
B)Two or more
C)Zero
D)Un-prototyped
E)None of these
Two or more
3
This is a statement that causes a function to execute.

A)for loop
B)do-while loop
C)function prototype
D)function call
E)None of these
function call
4
The value in this type of local variable persists between function calls.

A)global
B)internal
C)static
D)dynamic
E)None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
5
A function ________ contains the statements that make up the function.

A)definition
B)prototype
C)call
D)expression
E)parameter list
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
6
In a function header, you must furnish:

A)data type(s)of the parameters
B)data type of the return value
C)the name of function
D)names of parameter variables
E)All of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
7
It is a good programming practice to ________ your functions by writing comments that describe what they do.

A)execute
B)document
C)eliminate
D)prototype
E)None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
8
A function ________ eliminates the need to place a function definition before all calls to the function.

A)header
B)prototype
C)argument
D)parameter
E)None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
9
A function can have zero to many parameters, and it can return this many values.

A)zero to many
B)no
C)only one
D)a maximum of ten
E)None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
10
A ________ variable is declared outside all functions.

A)local
B)global
C)floating-point
D)counter
E)None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
11
When used as parameters, these types of variables allow a function to access the parameter's original argument.

A)reference
B)floating-point
C)counter
D)undeclared
E)None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
12
Given the following function definition: <strong>Given the following function definition:   What is the output of the following code fragment that invokes calc?  </strong> A)1 2 3 B)1 6 3 C)3 6 3 D)1 14 9 E)None of these
What is the output of the following code fragment that invokes calc?
<strong>Given the following function definition:   What is the output of the following code fragment that invokes calc?  </strong> A)1 2 3 B)1 6 3 C)3 6 3 D)1 14 9 E)None of these

A)1 2 3
B)1 6 3
C)3 6 3
D)1 14 9
E)None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
13
A function is executed when it is:

A)defined
B)prototyped
C)declared
D)called
E)None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
14
Which of the following statements about global variables is true?

A)A global variable is accessible only to the main function.
B)A global variable is declared in the highest-level block in which it is used.
C)A global variable can have the same name as a variable that is declared locally within a function.
D)If a function contains a local variable with the same name as a global variable, the global variable's name takes precedence within the function.
E)All of these are true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
15
This type of variable is defined inside a function and is not accessible outside the function.

A)global
B)reference
C)local
D)counter
E)None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
16
These types of arguments are passed to parameters automatically if no argument is provided in the function call.

A)Local
B)Default
C)Global
D)Relational
E)None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
17
A(n)________ is information that is passed to a function, and a(n)________ is information that is received by a function.

A)function call, function header
B)parameter, argument
C)argument, parameter
D)prototype, header
E)None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
18
This is a collection of statements that performs a specific task.

A)infinite loop
B)variable
C)constant
D)function
E)None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
19
Functions are ideal for use in menu-driven programs. When a user selects a menu item, the program can ________ the appropriate function.

A)call
B)prototype
C)define
D)declare
E)None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
20
This statement causes a function to end.

A)end
B)terminate
C)return
D)release
E)None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
21
A local variable and a global variable may not have the same name within the same program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
22
Look at the following function prototype.
<strong>Look at the following function prototype.   What is the data type of the function's return value?</strong> A)int B)double C)void D)Can't tell from the prototype
What is the data type of the function's return value?

A)int
B)double
C)void
D)Can't tell from the prototype
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
23
Look at the following function prototype.
<strong>Look at the following function prototype.   How many parameter variables does this function have?</strong> A)1 B)2 C)3 D)Can't tell from the prototype
How many parameter variables does this function have?

A)1
B)2
C)3
D)Can't tell from the prototype
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
24
What is the output of the following program?
<strong>What is the output of the following program?  </strong> A)5 B)2 C)7 D)getValue(x)

A)5
B)2
C)7
D)"getValue(x)"
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
25
Here is the header for a function named computeValue: void computeValue(int value)
Which of the following is a valid call to the function?

A)computeValue(10)
B)computeValue(10);
C)void computeValue(10);
D)void computeValue(int x);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
26
If a function does not have a prototype, default arguments may be specified in the function ________.

A)call
B)header
C)execution
D)return type
E)None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
27
What is the output of the following program?
<strong>What is the output of the following program?  </strong> A)   B)   C)   D)

A) <strong>What is the output of the following program?  </strong> A)   B)   C)   D)
B) <strong>What is the output of the following program?  </strong> A)   B)   C)   D)
C) <strong>What is the output of the following program?  </strong> A)   B)   C)   D)
D) <strong>What is the output of the following program?  </strong> A)   B)   C)   D)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
28
When a function is called, flow of control moves to the function's prototype.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
29
What is the output of the following program?
<strong>What is the output of the following program?  </strong> A) 2 2 B) 4 2 C) 2 4 D) 4 4

A)
2
2
B)
4
2
C)
2
4
D)
4
4
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
30
Which line in the following program contains the header for the showDub function?
<strong>Which line in the following program contains the header for the showDub function?  </strong> A)4 B)6 C)10 D)15

A)4
B)6
C)10
D)15
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
31
Look at the following function prototype.
<strong>Look at the following function prototype.   What is the data type of the function's parameter variable?</strong> A)int B)double C)void D)Can't tell from the prototype
What is the data type of the function's parameter variable?

A)int
B)double
C)void
D)Can't tell from the prototype
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
32
What is the output of the following program?
<strong>What is the output of the following program?  </strong> A)   B)   C)   D)

A) <strong>What is the output of the following program?  </strong> A)   B)   C)   D)
B) <strong>What is the output of the following program?  </strong> A)   B)   C)   D)
C) <strong>What is the output of the following program?  </strong> A)   B)   C)   D)
D) <strong>What is the output of the following program?  </strong> A)   B)   C)   D)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
33
Which line in the following program contains a call to the showDub function?
<strong>Which line in the following program contains a call to the showDub function?  </strong> A)4 B)6 C)10 D)15

A)4
B)6
C)10
D)15
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
34
The value in a ________ variable persists between function calls.

A)dynamic
B)local
C)counter
D)static local
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
35
A parameter is a special-purpose variable that is declared inside the parentheses of a function definition.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
36
This is a dummy function that is called instead of the actual function it represents.

A)main function
B)stub
C)driver
D)overloaded function
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
37
EXIT_FAILURE and ________ are named constants that may be used to indicate success or failure when the exit()function is called.

A)EXIT_TERMINATE
B)EXIT_SUCCESS
C)EXIT_OK
D)RETURN_OK
E)None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
38
Which line in the following program contains the prototype for the showDub function?
<strong>Which line in the following program contains the prototype for the showDub function?  </strong> A)4 B)6 C)10 D)15

A)4
B)6
C)10
D)15
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
39
A ________ argument is passed to a parameter when the actual argument is left out of the function call.

A)false
B)true
C)null
D)default
E)None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
40
If a function is called more than once in a program, the values stored in the function's local variables do not ________ between function calls.

A)persist
B)execute
C)communicate
D)change
E)None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
41
You must furnish an argument with a function call.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
42
It is not considered good programming practice to declare all of your variables globally.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
43
You may use the exit()function to terminate a program, regardless of which control mechanism is executing.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
44
A function's return data type must be the same as the function's parameter(s).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
45
A static variable that is defined within a function is initialized only once, the first time the function is called.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
46
It is possible for a function to have some parameters with default arguments and some without.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
47
One reason for using functions is to break programs into manageable units, or modules.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
48
Global variables are initialized to zero by default.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
49
Local variables are initialized to zero by default.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 49 في هذه المجموعة.