Deck 6: User-Defined Functions

ملء الشاشة (f)
exit full mode
سؤال
To use the predefined function tolower, the program must include the header file ____.

A)
B)
C)
D)
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
The standard header file for the abs(x)function is ____.

A)
B)
C)
D)
سؤال
The following function heading in a C++ program is valid:
int funcExp(int u, char v, float g)
سؤال
The following return statement returns the value 10.
return 10, 16;
سؤال
In C++, a function prototype is the function heading without the body of the function.
سؤال
Once you write and properly debug a function, you can use it in the program (or different programs) again and again without having to rewrite the same code repeatedly.
سؤال
The heading of the function is also called the ____.

A) title
B) function signature
C) function head
D) function header
سؤال
A variable or expression listed in a call to a function is called the ____.

A) formal parameter
B) actual parameter
C) data type
D) type of the function
سؤال
The output of the statement: cout << pow(2.0, pow(3.0, 1.0)) << endl;
Is ____.

A) 6.0
B) 7.0
C) 8.0
D) 9.0
سؤال
A variable listed in a header is known as a(n) ____ parameter.

A) actual
B) local
C) formal
D) function
سؤال
The function main is always compiled first, regardless of where in the program the function main is placed.
سؤال
The execution of a return statement in a user-defined function terminates the program.
سؤال
Assume the following. static_cast('a') = 97
Static_cast('A') = 65
The output of the statement:
Cout << static_cast(tolower('B')) << endl; is ____.

A) 65
B) 67
C) 96
D) 98
سؤال
Functions that do not have a return type are called ____ functions.

A) zero
B) null
C) void
D) empty
سؤال
The output of the statement: cout << pow(3.0, 2.0) + 5 << endl; is ____.

A) 11.0
B) 12.0
C) 13.0
D) 14.0
سؤال
The data type of a variable in a return statement must match the function type.
سؤال
Assume that all variables are properly declared. The following statement in a value-returning function is legal.
if (x % 2 == 0)
return x;
else
return x + 1;
سؤال
The output of the statement: cout << tolower('$') << endl;
Is ____.

A) '$'
B) '0'
C) '1'
D) An error, because you cannot use tolower with '$'.
سؤال
Using functions greatly enhances a program's readability because it reduces the complexity of the function main.
سؤال
If the formal parameter list of a function is empty, the parentheses after the function name are not needed.
سؤال
The statement: return 8, 10; returns the value ____.

A) 8
B) 10
C) 18
D) 80
سؤال
Given the following function: int strange(int x, int y)
{
If (x > y)
Return x + y;
Else
Return x - y;
}
What is the output of the following statement?
Cout << strange(4, 5) << endl;

A) -1
B) 1
C) 9
D) 20
سؤال
Given the following function prototype: int myFunc(int, int);, which of the following statements is valid? Assume that all variables are properly declared.

A) cin >> myFunc(y);
B) cout << myFunc(myFunc(7, 8), 15);
C) cin >> myFunc('2', '3');
D) cout << myFunc(myFunc(7), 15);
سؤال
When you attach & after the dataType in the formal parameter list of a function, the variable following that dataType becomes a(n) ____________________ parameter.
سؤال
If a formal parameter is a nonconstant reference parameter, during a function call, its corresponding actual parameter must be a(n) ____________________.
سؤال
Given the following function prototype: double tryMe(double, double);, which of the following statements is valid? Assume that all variables are properly declared.

A) cin >> tryMe(x);
B) cout << tryMe(2.0, 3.0);
C) cout << tryMe(tryMe(double, double), double);
D) cout << tryMe(tryMe(float, float), float);
سؤال
Given the following function: int next(int x)
{
Return (x + 1);
}
What is the output of the following statement?
Cout << next(next(5)) << endl;

A) 5
B) 6
C) 7
D) 8
سؤال
The statement: return 37, y, 2 * 3; returns the value ____.

A) 2
B) 3
C) y
D) 6
سؤال
Which statement below about prototypes and headers is true?

A) Parameter names must be listed in the prototype, but not necessarily in the header.
B) Prototypes end with a semicolon, but headers do not.
C) Headers should come before prototypes.
D) Headers end with a semicolon, but prototypes do not.
سؤال
A function prototype is ____.

A) a definition, but not a declaration
B) a declaration and a definition
C) a declaration, but not a definition
D) a comment line
سؤال
The statement: return 2 * 3 + 1, 1 + 5; returns the value ____.

A) 2
B) 3
C) 6
D) 7
سؤال
A(n) ____________________ parameter is a formal parameter that receives the location (memory address) of the corresponding actual parameter.
سؤال
Given the following function prototype: int test(float, char);, which of the following statements is valid?

A) cout << test(12, &);
B) cout << test("12.0", '&');
C) int u = test(5.0, '*');
D) cout << test('12', '&');
سؤال
Given the function prototype: double testAlpha(int u, char v, double t); which of the following statements is legal?

A) cout << testAlpha(5, 'A', 2);
B) cout << testAlpha( int 5, char 'A', int 2);
C) cout << testAlpha('5.0', 'A', '2.0');
D) cout << testAlpha(5.0, "65", 2.0);
سؤال
____________________ parameters are useful in three situations:
• When the value of the actual parameter needs to be changed
• When you want to return more than one value from a function
• When passing the address would save memory space and time relative to copying a large amount of data
سؤال
Given the function prototype: float test(int, int, int);
Which of the following statements is legal?

A) cout << test(7, test(14, 23));
B) cout << test(test(7, 14), 23);
C) cout << test(14, 23);
D) cout << test(7, 14, 23);
سؤال
A(n) ____________________ parameter s a formal parameter that receives a copy of the content of the corresponding actual parameter.
سؤال
Which of the following function prototypes is valid?

A) int funcTest(int x, int y, float z){}
B) funcTest(int x, int y, float){};
C) int funcTest(int, int y, float z)
D) int funcTest(int, int, float);
سؤال
What value is returned by the following return statement? int x = 5;
Return x + 1;

A) 0
B) 5
C) 6
D) 7
سؤال
Which of the following function prototypes is valid?

A) int funcExp(int x, float v);
B) funcExp(int x, float v){};
C) funcExp(void);
D) int funcExp(x);
سؤال
A function ____________________ is a function that is not fully coded.
سؤال
The program that tests a function is called a(n) ____________________ program.
سؤال
In C++, :: is called the ____________________.
سؤال
A variable for which memory is allocated at block entry and deallocated at block exit is called a(n) ____________________ variable.
سؤال
____________________ identifiers are not accessible outside of the function (block).
سؤال
The ____________________ of a function consists of the function name and its formal parameter list.
سؤال
If a function needs to return more than one value, as a rule of good programming style, you should change it to a(n) ____________________ function and use the appropriate reference parameters to return the values.
سؤال
The ____________________ of an identifier refers to where in the program an identifier is accessible (visible).
سؤال
Stream variables (for example, ifstream and ofstream) should be passed by ____________________ to a function.
سؤال
A variable for which memory remains allocated as long as the program executes is called a(n) ____________________ variable.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/50
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 6: User-Defined Functions
1
To use the predefined function tolower, the program must include the header file ____.

A)
B)
C)
D)
A
2
The standard header file for the abs(x)function is ____.

A)
B)
C)
D)
A
3
The following function heading in a C++ program is valid:
int funcExp(int u, char v, float g)
True
4
The following return statement returns the value 10.
return 10, 16;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
5
In C++, a function prototype is the function heading without the body of the function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
6
Once you write and properly debug a function, you can use it in the program (or different programs) again and again without having to rewrite the same code repeatedly.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
7
The heading of the function is also called the ____.

A) title
B) function signature
C) function head
D) function header
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
8
A variable or expression listed in a call to a function is called the ____.

A) formal parameter
B) actual parameter
C) data type
D) type of the function
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
9
The output of the statement: cout << pow(2.0, pow(3.0, 1.0)) << endl;
Is ____.

A) 6.0
B) 7.0
C) 8.0
D) 9.0
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
10
A variable listed in a header is known as a(n) ____ parameter.

A) actual
B) local
C) formal
D) function
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
11
The function main is always compiled first, regardless of where in the program the function main is placed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
12
The execution of a return statement in a user-defined function terminates the program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
13
Assume the following. static_cast('a') = 97
Static_cast('A') = 65
The output of the statement:
Cout << static_cast(tolower('B')) << endl; is ____.

A) 65
B) 67
C) 96
D) 98
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
14
Functions that do not have a return type are called ____ functions.

A) zero
B) null
C) void
D) empty
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
15
The output of the statement: cout << pow(3.0, 2.0) + 5 << endl; is ____.

A) 11.0
B) 12.0
C) 13.0
D) 14.0
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
16
The data type of a variable in a return statement must match the function type.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
17
Assume that all variables are properly declared. The following statement in a value-returning function is legal.
if (x % 2 == 0)
return x;
else
return x + 1;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
18
The output of the statement: cout << tolower('$') << endl;
Is ____.

A) '$'
B) '0'
C) '1'
D) An error, because you cannot use tolower with '$'.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
19
Using functions greatly enhances a program's readability because it reduces the complexity of the function main.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
20
If the formal parameter list of a function is empty, the parentheses after the function name are not needed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
21
The statement: return 8, 10; returns the value ____.

A) 8
B) 10
C) 18
D) 80
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
22
Given the following function: int strange(int x, int y)
{
If (x > y)
Return x + y;
Else
Return x - y;
}
What is the output of the following statement?
Cout << strange(4, 5) << endl;

A) -1
B) 1
C) 9
D) 20
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
23
Given the following function prototype: int myFunc(int, int);, which of the following statements is valid? Assume that all variables are properly declared.

A) cin >> myFunc(y);
B) cout << myFunc(myFunc(7, 8), 15);
C) cin >> myFunc('2', '3');
D) cout << myFunc(myFunc(7), 15);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
24
When you attach & after the dataType in the formal parameter list of a function, the variable following that dataType becomes a(n) ____________________ parameter.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
25
If a formal parameter is a nonconstant reference parameter, during a function call, its corresponding actual parameter must be a(n) ____________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
26
Given the following function prototype: double tryMe(double, double);, which of the following statements is valid? Assume that all variables are properly declared.

A) cin >> tryMe(x);
B) cout << tryMe(2.0, 3.0);
C) cout << tryMe(tryMe(double, double), double);
D) cout << tryMe(tryMe(float, float), float);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
27
Given the following function: int next(int x)
{
Return (x + 1);
}
What is the output of the following statement?
Cout << next(next(5)) << endl;

A) 5
B) 6
C) 7
D) 8
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
28
The statement: return 37, y, 2 * 3; returns the value ____.

A) 2
B) 3
C) y
D) 6
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
29
Which statement below about prototypes and headers is true?

A) Parameter names must be listed in the prototype, but not necessarily in the header.
B) Prototypes end with a semicolon, but headers do not.
C) Headers should come before prototypes.
D) Headers end with a semicolon, but prototypes do not.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
30
A function prototype is ____.

A) a definition, but not a declaration
B) a declaration and a definition
C) a declaration, but not a definition
D) a comment line
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
31
The statement: return 2 * 3 + 1, 1 + 5; returns the value ____.

A) 2
B) 3
C) 6
D) 7
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
32
A(n) ____________________ parameter is a formal parameter that receives the location (memory address) of the corresponding actual parameter.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
33
Given the following function prototype: int test(float, char);, which of the following statements is valid?

A) cout << test(12, &);
B) cout << test("12.0", '&');
C) int u = test(5.0, '*');
D) cout << test('12', '&');
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
34
Given the function prototype: double testAlpha(int u, char v, double t); which of the following statements is legal?

A) cout << testAlpha(5, 'A', 2);
B) cout << testAlpha( int 5, char 'A', int 2);
C) cout << testAlpha('5.0', 'A', '2.0');
D) cout << testAlpha(5.0, "65", 2.0);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
35
____________________ parameters are useful in three situations:
• When the value of the actual parameter needs to be changed
• When you want to return more than one value from a function
• When passing the address would save memory space and time relative to copying a large amount of data
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
36
Given the function prototype: float test(int, int, int);
Which of the following statements is legal?

A) cout << test(7, test(14, 23));
B) cout << test(test(7, 14), 23);
C) cout << test(14, 23);
D) cout << test(7, 14, 23);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
37
A(n) ____________________ parameter s a formal parameter that receives a copy of the content of the corresponding actual parameter.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
38
Which of the following function prototypes is valid?

A) int funcTest(int x, int y, float z){}
B) funcTest(int x, int y, float){};
C) int funcTest(int, int y, float z)
D) int funcTest(int, int, float);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
39
What value is returned by the following return statement? int x = 5;
Return x + 1;

A) 0
B) 5
C) 6
D) 7
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
40
Which of the following function prototypes is valid?

A) int funcExp(int x, float v);
B) funcExp(int x, float v){};
C) funcExp(void);
D) int funcExp(x);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
41
A function ____________________ is a function that is not fully coded.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
42
The program that tests a function is called a(n) ____________________ program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
43
In C++, :: is called the ____________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
44
A variable for which memory is allocated at block entry and deallocated at block exit is called a(n) ____________________ variable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
45
____________________ identifiers are not accessible outside of the function (block).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
46
The ____________________ of a function consists of the function name and its formal parameter list.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
47
If a function needs to return more than one value, as a rule of good programming style, you should change it to a(n) ____________________ function and use the appropriate reference parameters to return the values.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
48
The ____________________ of an identifier refers to where in the program an identifier is accessible (visible).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
49
Stream variables (for example, ifstream and ofstream) should be passed by ____________________ to a function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
50
A variable for which memory remains allocated as long as the program executes is called a(n) ____________________ variable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.