Question: Question 17 If a dowhile structure is used: Counter-controlled iteration is not possible. An infinite loop cannot take place. An off-by-one error cannot occur. The

Question 17

If a dowhile structure is used:

Counter-controlled iteration is not possible.

An infinite loop cannot take place.

An off-by-one error cannot occur.

The body of the loop will execute at least once.

Question 18

In C++, the condition (4 > y > 1):

Does not evaluate correctly and should be replaced by (4 > y && y > 1).

Evaluates correctly and could be replaced by (4 > y && y > 1).

Does not evaluate correctly and should NOT be replaced by (4 > y && y > 1).

Evaluates correctly and could NOT be replaced by (4 > y && y > 1).

Question 19

Which of the following initializes a vector with a list initializer:

vector integers{1, 2, 3, 4, 5, 6};

vector integers(1, 2, 3, 4, 5, 6);

vector integers{1, 2, 3, 4, 5, 6};

None of the choices.

Question 20

This question may have 0 to multiple answers. Choose all that apply. Assuming var is an int:

var++ adds 1 to var, returning the new var before the semicolon.

++var adds 1 to var, returning the new var before the semicolon.

var++ adds 1 to var, returning the old var before the semicolon.

++var adds 1 to var, returning the old var before the semicolon.

None of the choices.

Question 21

This question may have 0 to multiple answers. Choose all that apply. Which of the following is a valid way to retrieve the length of a C++ string, str?

str.length();

strlen(str);

strlen(str.c_str())+1;

None of the choices.

str.size();

Question 22

An array is a sequence of objects allocated in contiguous memory. That is, all elements of an array can be of different types and there are no gaps between them in the sequence.

True

False

Question 23

The following statements compile in C++:

int arr[10]; arr[-1] = 1; arr[10] = 2;

True

False

Question 24

The support for C-style strings are in

True

False

Question 25

What is the length of the resulting C-style string, str, after strcpy()?

char str[100]; strcpy(str, "C++");

4

3

100

101

Question 26

C++ style string is terminated by '\0'.

True

False

Question 27

Assuming str is an non-empty C-style string, is the following True or False?

sizeof(str) == strlen(str);

True

False

Question 28

If the variable x has the original value of 3.3, what is the output value after the following?

cout << static_cast(x);

3

2

3.3

4

undefined

3.0

Question 29

What is the value returned by the following function?

int function() { int value = 30; return value + 5; value += 10; }

Question 30

Assert terminates the program with a message when its boolean argument turns out to be TRUE.

True

False

Question 31

Multiple arguments to a function are separated by a

commas ','

period '.'

semicolons ';'

comments

Question 32

The functions pow(), sqrt(), and fabs() are found in which include file?

cstdlib

stdlib

iostream

cmath

std

Question 33

This question may have 0 to multiple answers. Choose all that apply. How do you concatenate two C++ strings, str1 and str2?

concate(str1, str2);

strconcate(str1, str2);

str1 = str2;

str1.add(str2);

str1 += str2;

For the remaining questions, use this Problem Description. You are asked to examine an arbitrary C++ string, and generate a list of characters and their occurrences, in ASCII order, from that string.

Example:

For an input string of "P C C?", we can see the repeated characters are ' ', 'C', 'P' and '?' with an empty space occurring 2 times, 'C' occurring 2 times, 'P' occurring 1 time, and '?' occurring 1 time. In ASCII order we have the following, with their count:

: 2 C: 2 P: 1 ?: 1

Question 34

Based on the Problem Description, the input may be the combination of any one of the 128 characters in the ASCII table (Links to an external site.)Links to an external site.. Write a STATEMENT (not the entire program) to create/instantiate an array of 128 characters called arr.

HTML EditorKeyboard Shortcuts

12pt

Paragraph

0 words

Question 35

Based on the Problem Description, we need to keep the character count for every one of the 128 possible characters. Which of the following statements illustrates the use of arr (array created from the last problem) to increment the ASCII_CHARACTER count by 1? ASCII_CHARACTER can be any one of the first 128 characters in the ASCII Table (Links to an external site.)Links to an external site. (not the Extended ASCII Table).

arr[ASCII_CHARACTER-97]++;

arr[ASCII_CHARACTER] = ASCII_CHARACTER++;

arr[ASCII_CHARACTER]++;

arr[ASCII_CHARACTER-65]++;

None of the choices.

Question 36

Based on the Problem Description and the previous questions, write a short code snippet (not the entire problem) to generate a dictionary of letter occurrences. Namely, print a list of input characters and their occurrences from an arbitrary C++ string, str. You may use cout() to print them to the console. Cut and paste your code snippet into the text box.

Input:

string str = "P C c?";

Output:

Your output is a character list in the ascending ASCII order (namely space ' ' appearing before '?', which appears before 'C' , which appears before 'P'. Finally, the lower case 'c' appears last):

: 2 ?: 1 C: 1 P: 1 c: 1

Constraints/Assumptions:

Your code should work with any characters in ASCII (i.e., the first 128 characters in the table http://www.asciitable.com (Links to an external site.)Links to an external site.).

The character must be printed in ascending ASCII order, separated by line break as seen above.

Only print characters from the input string.

Rubric:

(2 points) Correct ASCII order (ascending) separated by line break.

(5 points) Correct letter occurrences.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!