Deck 6: User-Defined Function

ملء الشاشة (f)
exit full mode
سؤال
A variable listed in a header is known as a(n) ____ parameter.

A) actual
B) local
C) formal
D) function
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
The data type of a variable in a return statement must match the function type.
سؤال
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 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
سؤال
If the formal parameter list of a function is empty, the parentheses after the function name are not needed.
سؤال
To use the predefined function tolower, the program must include the header file ____.

A)
B)
C)
D)
سؤال
The following function heading in a C++ program is valid:
int funcExp(int u, char v, float g)
سؤال
Functions that do not have a return type are called ____ functions.

A) zero
B) null
C) void
D) empty
سؤال
Assume the following. ​

<strong>Assume the following. ​ ​   The output of the statement: ​ Cout << static_cast<int>(tolower('B')) << endl; ​ Is ____.</strong> A) 65 B) 67 C) 96 D) 98 <div style=padding-top: 35px> The output of the statement:

Cout << static_cast(tolower('B')) << endl;

Is ____.

A) 65
B) 67
C) 96
D) 98
سؤال
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
سؤال
Using functions greatly enhances a program's readability because it reduces the complexity of the function main.
سؤال
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.
سؤال
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
سؤال
Assume that all variables are properly declared. The following statement in a value-returning function is legal.
Assume that all variables are properly declared. The following statement in a value-returning function is legal.  <div style=padding-top: 35px>
سؤال
The execution of a return statement in a user-defined function terminates the program.
سؤال
The function main is always compiled first, regardless of where in the program the function main is placed.
سؤال
The output of the statement: cout << tolower('$') << endl;
Is ____.

A) '$'
B) '0'
C) '1'
D) An error, because you cannot use tolower with '$'.
سؤال
The standard header file for the abs(x)function is ____.

A)
B)
C)
D)
سؤال
Given the following function: what is the output of the following statement?
Cout << next(next(5)) << endl;
<strong>Given the following function: what is the output of the following statement? Cout << next(next(5)) << endl;  </strong> A) 5 B) 6 C) 7 D) 8 <div style=padding-top: 35px>

A) 5
B) 6
C) 7
D) 8
سؤال
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? <strong>What value is returned by the following return statement?  </strong> A) 0 B) 5 C) 6 D) 7 <div style=padding-top: 35px>

A) 0
B) 5
C) 6
D) 7
سؤال
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);
سؤال
Stream variables (for example, ifstream and ofstream) should be passed by ____________________ to a function.
سؤال
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);
سؤال
Given the following function: what is the output of the following statement?
Cout << strange(4, 5) << endl;
<strong>Given the following function: what is the output of the following statement? Cout << strange(4, 5) << endl;  </strong> A) -1 B) 1 C) 9 D) 20 <div style=padding-top: 35px>

A) -1
B) 1
C) 9
D) 20
سؤال
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.
سؤال
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);
سؤال
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
سؤال
____________________ 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: ​
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);
سؤال
The statement: return 8, 10; returns the value ____.

A) 8
B) 10
C) 18
D) 80
سؤال
The statement: return 2 * 3 + 1, 1 + 5; returns the value ____.

A) 2
B) 3
C) 6
D) 7
سؤال
A function ____________________ is a function that is not fully coded.
سؤال
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 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', '&');
سؤال
When you attach & after the dataType in the formal parameter list of a function, the variable following that dataType becomes a(n) ____________________ parameter.
سؤال
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.
سؤال
The ____________________ of a function consists of the function name and its formal parameter list.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/41
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 6: User-Defined Function
1
A variable listed in a header is known as a(n) ____ parameter.

A) actual
B) local
C) formal
D) function
C
2
The data type of a variable in a return statement must match the function type.
True
3
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
D
4
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
5
If the formal parameter list of a function is empty, the parentheses after the function name are not needed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
6
To use the predefined function tolower, the program must include the header file ____.

A)
B)
C)
D)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
7
The following function heading in a C++ program is valid:
int funcExp(int u, char v, float g)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
8
Functions that do not have a return type are called ____ functions.

A) zero
B) null
C) void
D) empty
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
9
Assume the following. ​

<strong>Assume the following. ​ ​   The output of the statement: ​ Cout << static_cast<int>(tolower('B')) << endl; ​ Is ____.</strong> A) 65 B) 67 C) 96 D) 98 The output of the statement:

Cout << static_cast(tolower('B')) << endl;

Is ____.

A) 65
B) 67
C) 96
D) 98
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
10
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
11
The heading of the function is also called the ____.

A) title
B) function signature
C) function head
D) function header
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
12
Using functions greatly enhances a program's readability because it reduces the complexity of the function main.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
13
The following return statement returns the value 10.
return 10, 16;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
14
In C++, a function prototype is the function heading without the body of the function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
15
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
16
Assume that all variables are properly declared. The following statement in a value-returning function is legal.
Assume that all variables are properly declared. The following statement in a value-returning function is legal.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
17
The execution of a return statement in a user-defined function terminates the program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
18
The function main is always compiled first, regardless of where in the program the function main is placed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
19
The output of the statement: cout << tolower('$') << endl;
Is ____.

A) '$'
B) '0'
C) '1'
D) An error, because you cannot use tolower with '$'.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
20
The standard header file for the abs(x)function is ____.

A)
B)
C)
D)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
21
Given the following function: what is the output of the following statement?
Cout << next(next(5)) << endl;
<strong>Given the following function: what is the output of the following statement? Cout << next(next(5)) << endl;  </strong> A) 5 B) 6 C) 7 D) 8

A) 5
B) 6
C) 7
D) 8
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
22
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);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
23
What value is returned by the following return statement? <strong>What value is returned by the following return statement?  </strong> A) 0 B) 5 C) 6 D) 7

A) 0
B) 5
C) 6
D) 7
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
24
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);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
25
Stream variables (for example, ifstream and ofstream) should be passed by ____________________ to a function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
26
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);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
27
Given the following function: what is the output of the following statement?
Cout << strange(4, 5) << endl;
<strong>Given the following function: what is the output of the following statement? Cout << strange(4, 5) << endl;  </strong> A) -1 B) 1 C) 9 D) 20

A) -1
B) 1
C) 9
D) 20
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
28
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
29
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);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
31
____________________ 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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
32
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);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
33
The statement: return 8, 10; returns the value ____.

A) 8
B) 10
C) 18
D) 80
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
34
The statement: return 2 * 3 + 1, 1 + 5; returns the value ____.

A) 2
B) 3
C) 6
D) 7
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
35
A function ____________________ is a function that is not fully coded.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
36
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);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
37
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', '&');
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
38
When you attach & after the dataType in the formal parameter list of a function, the variable following that dataType becomes a(n) ____________________ parameter.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
39
The statement: return 37, y, 2 * 3; returns the value ____.

A) 2
B) 3
C) y
D) 6
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
40
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
41
The ____________________ of a function consists of the function name and its formal parameter list.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 41 في هذه المجموعة.