with Correct Answers
Which of the following statements is used to simplify the accessing of all globalType
namespace members? - Answer-using namespace globalType;
The identifiers in the system-provided header files such as iostream, cmath, and
iomanip are defined in the namespace ____. - Answer-std
Before using the data type string, the program must include the header file ____. -
Answer-string
Suppose that str1, str2, and str3 are string variables. After the following statements
execute, the value of str3 is "____".
str1 = "abc";
str2 = "xyz";
str3 = str1 + '-' + str2; - Answer-abc-xyz
Suppose str = "xyzw";. After the statement str[2] = 'Y'; The value of str is "____". -
Answer-xyYw
Suppose str = "ABCDEFGHI". The output of the statement
cout << str.length() << endl; - Answer-9
The length of the string "Hello There. " is ____. - Answer-13
11 Consider the following statements.
string str = "ABCDEFD";
string::size_type position;
After the statement position = str.find('D'); executes, the value of position is ____. -
Answer-3
11 Considering the statement string str = "Gone with the wind";, the output of the
statement cout << str.find("the") <<
endl; is ____. - Answer-10
, 11 Consider the following statements.
string str1 = "ABCDEFGHIJKLM";
string str2;
After the statement str2 = str1.substr(1,4); executes, the value of str2 is "____". -
Answer-BCDE
11 Consider the following statements.
string str1 = "Gone with the wind";
string str2;
After the statement str2 = str1.substr(5,4); executes, the value of str2 is "____". -
Answer-with
11 The ____ function is used to interchange the contents of two string variables. -
Answer-swap
11 Which of the following statements declares alpha to be an array of 25 components of
the type int? - Answer-int alpha[25];
Assume you have the following declaration int beta[50];. Which of the following is a valid
element of beta? - Answer-beta[0]
What is the output of the following loop?
count = 5;
cout << 'St';
do
{
cout << 'o';
count--;
}
while (count <= 5); - Answer-This is an infinite loop.
____ loops are called post-test loops. - Answer-do...while
Which of the following loops does not have an entry condition? - Answer-do...while loop
The ____ statement can be used to eliminate the use of certain bool variables in a loop.
- Answer-break
What executes immediately after a continue statement in a while and do-while loop? -
Answer-loop-continue test