Chapter 10
A test using the isupper function will return false if the argument is an uppercase character
False
Although C++ provides ample library functions to handle numeric values, we must write all of our own functions to manipulate character values.
False
The C++ compiler performs strict array bounds checking when it encounters an array of characters.
False
The following string that uses a semicolon as a delimiter contains four tokens: "apple;cherry;lemon cream"
False
The ftoa function converts a floating-point value to an ASCII value.
False
The strlen function returns a C-string's length and adds one for \0.
False
By being able to pass arrays as arguments, you can write your own functions for processing C-strings.
True
C++11 introduces a function named to_string that converts a numeric value to a string object.
True
If an uppercase character is passed as an argument to the toupper function, the result will be an uppercase character
True
The C++ library provides functions for converting a string representation of a number to a numeric data type and vice-versa.
True
The isdigit function will return true if the argument is a digit between 0 and 9.
True
The itoa function is similar to atoi but it works in reverse.
True
The string class's front and back member functions were introduced in C++11.
True
When using the strcat function you must be careful not to overwrite the bounds of an array.
True
You may use the <, >, <=, >=, ==, and != relational operators to compare string objects.
True
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
a. 1000
Select all that apply. Whitespace encompasses which of the following? a. a tab b. a newline c. a space d. None of these
a. a tab b. a newline c. a space
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
a. atol
To test whether a character is a printable character, use the __________ function. a. isprint b. isprintable c. isprintok d. isoktoprint e. None of these
a. isprint
Given the string shown below, if the delimiter is a space, how many tokens are in the string? "Tony's email address is [email protected]" a. 4 b. 5 c. 6 d. 7 e. 9
b. 5
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
b. char str[50];
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
b. ispunct
To determine whether a character entered is whitespace, use the __________ function. a. iswhite b. isspace c. iswhitespace d. isblank e. None of these
b. isspace
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
b. lowercase z
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
b. strncpy
A library function that can find one C-string inside another is a. strcmp b. strstr c. strfind d. strsearch e. None of these
b. strstr
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
b. the first character of mystring
The __________ function will change a character argument from uppercase to lowercase. a. islower b. tolower c. atoi d. toupper e. None of these
b. tolower
The __________ function will change a character argument from lowercase to uppercase. a. isupper b. toupper c. tolarge d. fromlower e. None of these
b. toupper
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
b. two addresses
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
b. var1 stores the ASCII value for lowercase 'a'
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
c. #include<cstring>
The escape sequence that represents the null terminator is a. \n b. \t c. \0 d. nullptr e. None of these
c. \0
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
c. atoi
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
c. atoi("10");
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
a. tolower c. toupper
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
c. char name[26];
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
c. eleven characters and the null terminator
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
c. null character
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
c. strcat
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
c. strlen
The null terminator stands for ASCII code a. 57 b. 100 c. 1000 d. 0 e. None of these
d. 0
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
d. atoi
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
d. both A and C
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
d. isalpha
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
d. isdigit
The function that reverses the order of a C-string is a. reversstr b. strrev c. reverseit d. back e. None of these
e. None of these