 |
|
 |
 |
 |
 |
 |
|
|
|
|
|
Practice Quiz 6 - Working with Strings and Characters
There
are 10 questions in this quiz
Question 1: Multiple Choice
Which one of the following functions returns an integer
value from a string?
Question 2: Multiple Choice 
Examine the following code.
int
len;
len = strlen("howdy
partner");
What is the value of len?
Question 3: Multiple Choice 
Examine the following code.
int
result;
char str[10] = "Hi
there!";
result = strcmp(str, "Hi
there!");
What would the value of result be?
Question 4: Multiple Choice 
Examine the following code.
char
FirstName1[15] = "Angela";
char
FirstName2[15] = "Ang";
result
= strncmp(FirstName, LastName, 3);
cout
<< result;
What would the value of result be?
Question 5: Multiple Choice 
Examine the following code.
char strBuffer[7];
strncpy(strBuffer, "hello",5);
cout << strBuffer
<< endl;
What would the output be?
Question 6: Multiple Choice
Examine the code below.
char
str[] = “1234.5”;
int
num;
num
= atoi(str);
cout
<< “number = ” << num << endl;
What
will be output?
Question 7: Multiple Choice
Examine the following code.
int
ch = 100;
cout << "The ASCII value of
" << ch << " is " << 100 << endl;
What would the output be?
Question 8: Multiple Choice
Examine the code below.
char
str1[] = "0895-673-9900";
char
str2[]= "0000 is your telephone code";
double
num;
strncpy(str2,
str1, 4);
cout
<< str2 << endl;
What
will be output?
Question 9: Multiple Choice
Examine the following code.
char s1[] = "Howdy";
char s2[20];
for
(int index = 0; index < strlen(s1); index++) {
s2[index]
= toupper(s1[index]);
}
s2[index]
= '\0';
What will the output be?
Question 10: Multiple Choice
Examine the code below.
char str1[] = "1234.5";
char str2[] = "abcdefghi";
strncpy (str2,str1, 6);
cout << atof(str2) << ", " << atoi(str2);
What will be output to the console from the following
code?
|
|
|