Deck 10: Characters, C-Strings, and More About the String Class

Full screen (f)
exit full mode
Question
A practical application of this function is to allow a user to enter a response of 'y' or 'Y' to a prompt.

A)tolower
B)toupper
C)A or B
D)ignorecase
E)None of these
Use Space or
up arrow
down arrow
to flip the card.
Question
This function converts a C-string to an integer and returns the integer value.

A)atoint
B)strtoint
C)strint
D)atoi
E)None of these
Question
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 the above
Question
The null terminator stands for this ASCII code.

A)57
B)100
C)1000
D)0
E)None of these
Question
Which statement 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
Question
This is the escape sequence representing the null terminator.

A)\n
B)\t
C)\0
D)nullptr
E)None of these
Question
To change a character argument from lower to upper case, use this function.

A)isupper
B)toupper
C)tolarge
D)fromlower
E)None of these
Question
What is the output of the following statement?
<strong>What is the output of the following statement?  </strong> A)upper case Z B)lower case z C)a lower case z followed by an upper case Z D)a compiler error E)None of these <div style=padding-top: 35px>

A)upper case Z
B)lower case z
C)a lower case z followed by an upper case Z
D)a compiler error
E)None of these
Question
This function accepts a pointer to a C-string as an argument, and it returns the length of the C-string (not including the null terminator).

A)numchar
B)strlength
C)strlen
D)countstring
E)None of these
Question
To determine whether a character entered is a letter of the alphabet, use this function.

A)isdigit
B)fromkeyboard
C)alphaok
D)isalpha
E)None of these
Question
To test whether a character is a printable character, use this function.

A)isprint
B)isprintable
C)isprintok
D)isoktoprint
E)None of these
Question
This function accepts a C-string containing a number as its argument and returns the integer equivalent.

A)strToInt
B)itoa
C)atoi
D)int_from
E)None of these
Question
Look at the following statement. <strong>Look at the following statement.   The expression being tested by this statement will evaluate to true if var1 is:</strong> A)an alphabetic character B)9 C)a symbol such as $ or & D)both A and C E)None of these <div style=padding-top: 35px>
The expression being tested by this statement will evaluate to true if var1 is:

A)an alphabetic character
B)9
C)a symbol such as $ or &
D)both A and C
E)None of these
Question
This function will return true if its argument is a printable character other than a digit, letter, or space.

A)isprint
B)ispunct
C)ischar
D)isnotdls
E)None of these
Question
To test whether a character is a numeric digit character, use this function.

A)isnumber
B)notAlpha
C)isnumeric
D)isdigit
E)None of these
Question
This function accepts a C-string as an argument and converts the string to a long integer.

A)atol
B)strlong
C)strtolong
D)stringlong
E)None of these
Question
The strcpy function's arguments are:

A)two C-strings
B)two addresses
C)three pointers
D)one array and one pointer
E)None of these
Question
A library function that can find one C- string inside another is:

A)strcmp
B)strstr
C)strfind
D)strsearch
E)None of these
Question
To determine whether a character is whitespace, use this function.

A)iswhite
B)isspace
C)iswhitespace
D)isblank
E)None of these
Question
"Whitespace" encompasses which of the following?

A)tab
B)newline
C)space
D)All of these
E)None of these
Question
A test using the isupper function will return false if the argument is an uppercase character.
Question
To define a C-string that will store students' last names of up to 25 characters in length, which is an appropriate statement?

A)char lastName[25];
B)string lastName[25];
C)char lastName[26];
D)string lastName[24];
E)None of these
Question
The C++ library provides functions for converting a string representation of a number to a numeric data type, and vice-versa.
Question
Which of the following lines of code 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 the above
Question
To use the strlen function in a program, you must also write #include ________.

A)
B)
C)
D)
E)None of these
Question
When using the strcat function, you must be careful not to overwrite the bounds of an array.
Question
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
Question
The itoa function is similar to atoi, but it works in reverse.
Question
The ftoa function converts a floating-point value to an ASCII value.
Question
By being able to pass arrays as arguments, you can write your own functions for processing C-strings.
Question
This function accepts pointers to two C-strings and an integer argument, which indicates how many characters to copy from the second C-string to the first.

A)strcpy
B)strncpy
C)copystring
D)strintcpy
E)None of these
Question
This function concatenates the contents of one C-string with another C-string.

A)strcopy
B)strappend
C)strcat
D)stradd
E)None of these
Question
If a C-string that cannot be converted to a numeric value is passed to the atoi function, the function's behavior is undefined by C++.
Question
The C++ compiler performs strict array bounds checking when it encounters an array of characters.
Question
The statement:
<strong>The statement:   Will result in:</strong> A)var1 storing the character value 'A'. B)var1 storing the ASCII value for lower case 'a'. C)A is output to the monitor. D)a is output to the monitor. E)None of these <div style=padding-top: 35px>
Will result in:

A)var1 storing the character value 'A'.
B)var1 storing the ASCII value for lower case 'a'.
C)A is output to the monitor.
D)a is output to the monitor.
E)None of these
Question
The isdigit function will return a true if its argument is a digit between 0 and 9.
Question
This library function reverses the order of a C-string.

A)reverstr
B)strrev
C)reversit
D)backward
E)None of these
Question
To change a lower case character to an upper case character, use this function.

A)atoi
B)itoa
C)ltou
D)toupper
E)None of these
Question
The strlen function returns a C-string's length and adds one for \0.
Question
After the following statement executes, what value is stored in the variable num?
<strong>After the following statement executes, what value is stored in the variable num?  </strong> A)1000 B)999 (1000 minus 1 for the null terminator) C)1000 D)thousand E)None of these <div style=padding-top: 35px>

A)1000
B)999 (1000 minus 1 for the null terminator)
C)"1000"
D)"thousand"
E)None of these
Question
C++ 11 introduces a function named to_string that converts a numeric value to a string object.
Question
The string class's front and back member functions were introduced in C++ 11.
Question
You may use the <, >, <=, >=, ==, and != relational operators to compare string objects.
Question
If an uppercase character is passed as an argument to toupper, the result will be an uppercase character.
Question
Although C++ provides ample library functions to handle numeric values, we must write all of our own functions to manipulate character values.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/45
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 10: Characters, C-Strings, and More About the String Class
1
A practical application of this function is to allow a user to enter a response of 'y' or 'Y' to a prompt.

A)tolower
B)toupper
C)A or B
D)ignorecase
E)None of these
A or B
2
This function converts a C-string to an integer and returns the integer value.

A)atoint
B)strtoint
C)strint
D)atoi
E)None of these
atoi
3
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 the above
eleven characters and the null terminator
4
The null terminator stands for this ASCII code.

A)57
B)100
C)1000
D)0
E)None of these
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
5
Which statement 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
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
6
This is the escape sequence representing the null terminator.

A)\n
B)\t
C)\0
D)nullptr
E)None of these
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
7
To change a character argument from lower to upper case, use this function.

A)isupper
B)toupper
C)tolarge
D)fromlower
E)None of these
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
8
What is the output of the following statement?
<strong>What is the output of the following statement?  </strong> A)upper case Z B)lower case z C)a lower case z followed by an upper case Z D)a compiler error E)None of these

A)upper case Z
B)lower case z
C)a lower case z followed by an upper case Z
D)a compiler error
E)None of these
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
9
This function accepts a pointer to a C-string as an argument, and it returns the length of the C-string (not including the null terminator).

A)numchar
B)strlength
C)strlen
D)countstring
E)None of these
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
10
To determine whether a character entered is a letter of the alphabet, use this function.

A)isdigit
B)fromkeyboard
C)alphaok
D)isalpha
E)None of these
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
11
To test whether a character is a printable character, use this function.

A)isprint
B)isprintable
C)isprintok
D)isoktoprint
E)None of these
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
12
This function accepts a C-string containing a number as its argument and returns the integer equivalent.

A)strToInt
B)itoa
C)atoi
D)int_from
E)None of these
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
13
Look at the following statement. <strong>Look at the following statement.   The expression being tested by this statement will evaluate to true if var1 is:</strong> A)an alphabetic character B)9 C)a symbol such as $ or & D)both A and C E)None of these
The expression being tested by this statement will evaluate to true if var1 is:

A)an alphabetic character
B)9
C)a symbol such as $ or &
D)both A and C
E)None of these
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
14
This function will return true if its argument is a printable character other than a digit, letter, or space.

A)isprint
B)ispunct
C)ischar
D)isnotdls
E)None of these
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
15
To test whether a character is a numeric digit character, use this function.

A)isnumber
B)notAlpha
C)isnumeric
D)isdigit
E)None of these
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
16
This function accepts a C-string as an argument and converts the string to a long integer.

A)atol
B)strlong
C)strtolong
D)stringlong
E)None of these
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
17
The strcpy function's arguments are:

A)two C-strings
B)two addresses
C)three pointers
D)one array and one pointer
E)None of these
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
18
A library function that can find one C- string inside another is:

A)strcmp
B)strstr
C)strfind
D)strsearch
E)None of these
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
19
To determine whether a character is whitespace, use this function.

A)iswhite
B)isspace
C)iswhitespace
D)isblank
E)None of these
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
20
"Whitespace" encompasses which of the following?

A)tab
B)newline
C)space
D)All of these
E)None of these
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
21
A test using the isupper function will return false if the argument is an uppercase character.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
22
To define a C-string that will store students' last names of up to 25 characters in length, which is an appropriate statement?

A)char lastName[25];
B)string lastName[25];
C)char lastName[26];
D)string lastName[24];
E)None of these
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
23
The C++ library provides functions for converting a string representation of a number to a numeric data type, and vice-versa.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
24
Which of the following lines of code 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 the above
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
25
To use the strlen function in a program, you must also write #include ________.

A)
B)
C)
D)
E)None of these
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
26
When using the strcat function, you must be careful not to overwrite the bounds of an array.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
27
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
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
28
The itoa function is similar to atoi, but it works in reverse.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
29
The ftoa function converts a floating-point value to an ASCII value.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
30
By being able to pass arrays as arguments, you can write your own functions for processing C-strings.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
31
This function accepts pointers to two C-strings and an integer argument, which indicates how many characters to copy from the second C-string to the first.

A)strcpy
B)strncpy
C)copystring
D)strintcpy
E)None of these
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
32
This function concatenates the contents of one C-string with another C-string.

A)strcopy
B)strappend
C)strcat
D)stradd
E)None of these
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
33
If a C-string that cannot be converted to a numeric value is passed to the atoi function, the function's behavior is undefined by C++.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
34
The C++ compiler performs strict array bounds checking when it encounters an array of characters.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
35
The statement:
<strong>The statement:   Will result in:</strong> A)var1 storing the character value 'A'. B)var1 storing the ASCII value for lower case 'a'. C)A is output to the monitor. D)a is output to the monitor. E)None of these
Will result in:

A)var1 storing the character value 'A'.
B)var1 storing the ASCII value for lower case 'a'.
C)A is output to the monitor.
D)a is output to the monitor.
E)None of these
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
36
The isdigit function will return a true if its argument is a digit between 0 and 9.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
37
This library function reverses the order of a C-string.

A)reverstr
B)strrev
C)reversit
D)backward
E)None of these
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
38
To change a lower case character to an upper case character, use this function.

A)atoi
B)itoa
C)ltou
D)toupper
E)None of these
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
39
The strlen function returns a C-string's length and adds one for \0.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
40
After the following statement executes, what value is stored in the variable num?
<strong>After the following statement executes, what value is stored in the variable num?  </strong> A)1000 B)999 (1000 minus 1 for the null terminator) C)1000 D)thousand E)None of these

A)1000
B)999 (1000 minus 1 for the null terminator)
C)"1000"
D)"thousand"
E)None of these
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
41
C++ 11 introduces a function named to_string that converts a numeric value to a string object.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
42
The string class's front and back member functions were introduced in C++ 11.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
43
You may use the <, >, <=, >=, ==, and != relational operators to compare string objects.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
44
If an uppercase character is passed as an argument to toupper, the result will be an uppercase character.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
45
Although C++ provides ample library functions to handle numeric values, we must write all of our own functions to manipulate character values.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 45 flashcards in this deck.