Characters, C-Strings, And More + Test Bank + Answers Ch.10 - Test Bank | C++ Control Structures 9e by Tony Gaddis. DOCX document preview.

Characters, C-Strings, And More + Test Bank + Answers Ch.10

Starting Out with C++ from Control Structures to Objects, 9e (Gaddis)

Chapter 10 Characters, C-Strings, and More about the string Class

TRUE/FALSE

1. A test using the isupper function will return false if the argument is an uppercase character.

2. The isdigit function will return true if the argument is a digit between 0 and 9.

3. When using the strcat function you must be careful not to overwrite the bounds of an array.

4. The itoa function is similar to atoi but it works in reverse.

5. The C++ compiler performs strict array bounds checking when it encounters an array of characters.

6. The strlen function returns a C-string's length and adds one for \0.

7. The ftoa function converts a floating-point value to an ASCII value.

8. By being able to pass arrays as arguments, you can write your own functions for processing C-strings.

9. The C++ library provides functions for converting a string representation of a number to a numeric data type and vice-versa.

10. If an uppercase character is passed as an argument to the toupper function, the result will be an uppercase character.

11. You may use the <, >, <=, >=, ==, and != relational operators to compare string objects.

12. C++11 introduces a function named to_string that converts a numeric value to a string object.

13. The string class's front and back member functions were introduced in C++11.

14. Although C++ provides ample library functions to handle numeric values, we must write all of our own functions to manipulate character values.

15. The following string that uses a semicolon as a delimiter contains four tokens:

"apple;cherry;lemon cream"

MULTIPLE CHOICE

1. To test whether a character is a numeric digit character, use the __________ function.

a.

isnumber

b.

notAlpha

c.

isnumeric

d.

isdigit

e.

None of these

2. To test whether a character is a printable character, use the __________ function.

a.

isprint

b.

isprintable

c.

isprintok

d.

isoktoprint

e.

None of these

3. The escape sequence that represents the null terminator is

a.

\n

b.

\t

c.

\0

d.

nullptr

e.

None of these

4. The function that accepts a pointer to a C-string as an argument and returns the length of the C-string, not including the null terminator is

a.

numchar

b.

strlength

c.

strlen

d.

countstring

e.

None of these

5. The null terminator stands for ASCII code

a.

57

b.

100

c.

1000

d.

0

e.

None of these

6. The arguments of the strcpy function are

a.

two C-strings

b.

two addresses

c.

three pointers

d.

one array and one pointer

e.

None of these

7. A library function that can find one C-string inside another is

a.

strcmp

b.

strstr

c.

strfind

d.

strsearch

e.

None of these

8. The function that accepts a C-string as an argument and converts the string to a long integer is

a.

atol

b.

strlong

c.

strtolong

d.

stringlong

e.

None of these

9. The function that converts a C-string to an integer and returns the integer value is

a.

atoint

b.

strtoint

c.

strint

d.

atoi

e.

None of these

10. Which of the following converts the string "10" to the integer value 10?

a.

itoa("ten");

b.

atoi("ten");

c.

atoi("10");

d.

itoa(10);

e.

None of these

11. Which of the following will return true if the argument is a printable character other than a digit, letter, or space?

a.

isprint

b.

ispunct

c.

ischar

d.

isnotdls

e.

None of these

12. The C-string company[12] can hold

a.

twelve characters

b.

thirteen characters

c.

eleven characters and the null terminator

d.

twelve characters and the null terminator

e.

None of these

13. The expression being tested by the statement shown below will evaluate to true if var1 is __________.

if (!isdigit(var1))

a.

an alphabetic character

b.

9

c.

a symbol such as $ or &

d.

both A and C

e.

None of these

14. The function that accepts a C-string containing a number as its argument and returns the integer equivalent is

a.

strToInt

b.

itoa

c.

atoi

d.

int_from

e.

None of these

15. To determine whether a character entered is a letter of the alphabet, use the __________ function.

a.

isdigit

b.

fromkeyboard

c.

alpaok

d.

isalpha

e.

None of these

16. To determine whether a character entered is whitespace, use the __________ function.

a.

iswhite

b.

isspace

c.

iswhitespace

d.

isblank

e.

None of these

17. The __________ function will change a character argument from lowercase to uppercase.

a.

isupper

b.

toupper

c.

tolarge

d.

fromlower

e.

None of these

18. The __________ function will change a character argument from uppercase to lowercase.

a.

islower

b.

tolower

c.

atoi

d.

toupper

e.

None of these

19. What is the output of the following statement?

cout << tolower(toupper('Z')) << endl;

a.

uppercase Z

b.

lowercase z

c.

a lowercase z followed by an uppercase Z

d.

a compiler error

e.

None of these

20. In C++ a C-string is a sequence of characters stored in consecutive memory, terminated by a

a.

period

b.

space

c.

null character

d.

semicolon

e.

None of these

21. The __________ function concatenates the contents of one C-string with another C-string.

a.

strcopy

b.

strappend

c.

strcat

d.

stradd

e.

None of these

22. To use the strlen function in a program you must include

a.

#include<strlen>

b.

#include<iostring>

c.

#include<cstring>

d.

#include<stringlib>

e.

None of these

23. The function that accepts pointers to two C-strings and an integer argument that indicates how many characters to copy from the second string to the first is

a.

strcpy

b.

strncpy

c.

copystring

d.

strintcpy

e.

None of these

24. The function that reverses the order of a C-string is

a.

reversstr

b.

strrev

c.

reverseit

d.

back

e.

None of these

25. What is the value stored in num after the following statement executes?

num = atoi("1000");

a.

1000

b.

999

c.

"1000"

d.

"1 thousand"

e.

None of these

26. Which of the following statements appropriately defines a C-string that stores names of up to 25 characters?

a.

char name[25];

b.

string name[25];

c.

char name[26];

d.

string name[24];

e.

None of these

27. Which of the following defines an array of C-strings that will hold 49 characters and the null terminator?

a.

char [49];

b.

char str[50];

c.

char[50] str;

d.

character str[50];

e.

None of these

28. What is the result after the following statement executes?

char var1 = tolower('A');

a.

var1 stores the character value 'A'

b.

var1 stores the ASCII value for lowercase 'a'

c.

the character A is output to the monitor

d.

the character a is output to the monitor

e.

None of these

29. Given the string shown below, if the delimiter is a space, how many tokens are in the string?

"Tony's email address is tony_g@mycollege.edu"

a.

4

b.

5

c.

6

d.

7

e.

9

30. In C++11, assuming mychar is a char variable and mystring is a string, what is the value of mychar after the following statement executes?

mychar = mystring.front();

a.

the ASCII value of the first character of mystring

b.

the first character of mystring

c.

nothing, the function is missing an argument

d.

this will cause a compiler error

MULTIPLE RESPONSE

1. Select all that apply. Which of the following would be appropriate in a program that allows the user to enter either an uppercase or lowercase character in response to a prompt?

a.

tolower

b.

ignorecase

c.

toupper

d.

ignoreupper

e.

ignorelower

2. Select all that apply. Whitespace encompasses which of the following?

a.

a tab

b.

a newline

c.

a space

d.

None of these

Document Information

Document Type:
DOCX
Chapter Number:
10
Created Date:
Aug 21, 2025
Chapter Name:
Chapter 10 Characters, C-Strings, And More About The String Class
Author:
Tony Gaddis

Connected Book

Test Bank | C++ Control Structures 9e

By Tony Gaddis

Test Bank General
View Product →

$24.99

100% satisfaction guarantee

Buy Full Test Bank

Benefits

Immediately available after payment
Answers are available after payment
ZIP file includes all related files
Files are in Word format (DOCX)
Check the description to see the contents of each ZIP file
We do not share your information with any third party