978-1337102087 Chapter 6

subject Type Homework Help
subject Pages 9
subject Words 493
subject Authors D. S. Malik

Unlock document.

This document is partially blurred.
Unlock all pages and 1 million more documents.
Get Access
page-pf1
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 1
1. Using functions greatly enhances a program’s readability because it reduces the complexity of the function main.
a.
True
b.
False
ANSWER:
True
POINTS:
1
REFERENCES:
346
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:39 PM
DATE MODIFIED:
10/5/2016 1:39 PM
2. 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.
a.
True
b.
False
ANSWER:
True
POINTS:
1
REFERENCES:
352
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:39 PM
DATE MODIFIED:
10/5/2016 1:39 PM
3. If the formal parameter list of a function is empty, the parentheses after the function name are not needed.
a.
True
b.
False
ANSWER:
False
POINTS:
1
REFERENCES:
356
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:39 PM
DATE MODIFIED:
10/5/2016 1:39 PM
4. The following function heading in a C++ program is valid:
int funcExp(int u, char v, float g)
a.
True
b.
False
ANSWER:
True
POINTS:
1
REFERENCES:
356
QUESTION TYPE:
True / False
page-pf2
Name:
Class:
Date:
page-pf3
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 3
b.
False
ANSWER:
True
POINTS:
1
REFERENCES:
363
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:39 PM
DATE MODIFIED:
10/5/2016 1:39 PM
9. The following return statement returns the value 10.
return 10, 16;
a.
True
b.
False
ANSWER:
False
POINTS:
1
REFERENCES:
363
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:39 PM
DATE MODIFIED:
10/5/2016 1:39 PM
10. The function main is always compiled first, regardless of where in the program the function main is placed.
a.
True
b.
False
ANSWER:
False
POINTS:
1
REFERENCES:
375
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:39 PM
DATE MODIFIED:
10/5/2016 1:39 PM
11. The standard header file for the abs(x)function is ____.
a.
<cmath>
b.
<ioinput>
c.
<cctype>
d.
<cstdlib>
ANSWER:
a
POINTS:
1
REFERENCES:
349
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:39 PM
DATE MODIFIED:
10/5/2016 1:39 PM
page-pf4
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 4
12. To use the predefined function tolower, the program must include the header file ____.
a.
<cctype>
b.
<iostream>
c.
<cmath>
d.
<cstdlib>
ANSWER:
a
POINTS:
1
REFERENCES:
350
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:39 PM
DATE MODIFIED:
10/5/2016 1:39 PM
13. The output of the statement:
cout << tolower('$') << endl;
is ____.
a.
'$'
b.
'0'
c.
'1'
d.
An error, because you cannot use tolower with '$'.
ANSWER:
a
POINTS:
1
REFERENCES:
350
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:39 PM
DATE MODIFIED:
10/5/2016 1:39 PM
14. Assume the following.
static_cast<int>('a') = 97
static_cast<int>('A') = 65
The output of the statement:
cout << static_cast<int>(tolower('B')) << endl;
is ____.
a.
65
b.
67
c.
96
d.
98
ANSWER:
d
POINTS:
1
REFERENCES:
350
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:39 PM
page-pf5
Name:
Class:
Date:
page-pf6
Name:
Class:
Date:
page-pf7
Name:
Class:
Date:
page-pf8
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 8
25. 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);
ANSWER:
b
POINTS:
1
REFERENCES:
361-362
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:39 PM
DATE MODIFIED:
10/16/2016 9:29 AM
26. 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);
ANSWER:
a
POINTS:
1
REFERENCES:
361-362
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:39 PM
DATE MODIFIED:
10/16/2016 9:30 AM
27. 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);
ANSWER:
d
POINTS:
1
REFERENCES:
361-362
page-pf9
Name:
Class:
Date:
page-pfa
Name:
Class:
Date:
page-pfb
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 11
return x y;
}
what is the output of the following statement?
cout << strange(4, 5) << endl;
a.
-1
b.
1
c.
9
d.
20
ANSWER:
a
POINTS:
1
REFERENCES:
363
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:39 PM
DATE MODIFIED:
10/5/2016 1:39 PM
35. What value is returned by the following return statement?
int x = 5;
return x + 1;
a.
0
b.
5
c.
6
d.
7
ANSWER:
c
POINTS:
1
REFERENCES:
363
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:39 PM
DATE MODIFIED:
10/5/2016 1:39 PM
36. When you attach & after the dataType in the formal parameter list of a function, the variable following that
dataType becomes a(n) ____________________ parameter.
ANSWER:
reference
POINTS:
1
REFERENCES:
380
QUESTION TYPE:
Completion
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:39 PM
DATE MODIFIED:
10/5/2016 1:39 PM
37. ____________________ 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
page-pfc
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 12
ANSWER:
Reference
reference
POINTS:
1
REFERENCES:
386
QUESTION TYPE:
Completion
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:39 PM
DATE MODIFIED:
10/5/2016 1:39 PM
38. Stream variables (for example, ifstream and ofstream) should be passed by ____________________ to a
function.
ANSWER:
reference
POINTS:
1
REFERENCES:
390
QUESTION TYPE:
Completion
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:39 PM
DATE MODIFIED:
10/5/2016 1:39 PM
39. 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.
ANSWER:
void
POINTS:
1
REFERENCES:
399
QUESTION TYPE:
Completion
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:39 PM
DATE MODIFIED:
10/5/2016 1:39 PM
40. A function ____________________ is a function that is not fully coded.
ANSWER:
stub
POINTS:
1
REFERENCES:
414
QUESTION TYPE:
Completion
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:39 PM
DATE MODIFIED:
10/5/2016 1:39 PM
41. The ____________________ of a function consists of the function name and its formal parameter list.
ANSWER:
signature
POINTS:
1
REFERENCES:
416
QUESTION TYPE:
Completion
HAS VARIABLES:
False
page-pfd
Name:
Class:
Date:

Trusted by Thousands of
Students

Here are what students say about us.

Copyright ©2022 All rights reserved. | CoursePaper is not sponsored or endorsed by any college or university.