Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.This question may have 0 to multiple answers. Choose all that apply. Consider the following for loop: for (int x = 1; x < 5;

1.This question may have 0 to multiple answers. Choose all that apply. Consider the following for loop:

for (int x = 1; x < 5; increment) { cout << x + 1 << endl; } 

If the last value printed is 5, which of the following might have been used for increment?

A x++
B ++x
C x += 1
D None of the choices.

2.If a dowhile structure is used:

A Counter-controlled iteration is not possible.
B An infinite loop cannot take place.
C An off-by-one error cannot occur.
D The body of the loop will execute at least once.

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

A

Does not evaluate correctly and should be replaced by (4 > y && y > 1).
B Evaluates correctly and could be replaced by (4 > y && y > 1).
C Does not evaluate correctly and should NOT be replaced by (4 > y && y > 1).
D Evaluates correctly and could NOT be replaced by (4 > y && y > 1).

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

A vector integers{1, 2, 3, 4, 5, 6};
B vector integers(1, 2, 3, 4, 5, 6);
C vector integers{1, 2, 3, 4, 5, 6};
D None of the choices.

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

A var++ adds 1 to var, returning the new var before the semicolon.
B ++var adds 1 to var, returning the new var before the semicolon.
C var++ adds 1 to var, returning the old var before the semicolon.
D ++var adds 1 to var, returning the old var before the semicolon.
E None of the choices.

6.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?

A str.length();
B strlen(str);
C strlen(str.c_str())+1;
D None of the choices.
E str.size();

7.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.

A True
B False

8.The following statements compile in C++:

int arr[10]; arr[-1] = 1; arr[10] = 2;
A True
B False

9.The support for C-style strings are in

A True
B False

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

char str[100]; strcpy(str, "C++");
A 4
B 3
C 100
D 101

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

A True
B False

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

sizeof(str) == strlen(str);
A True
B False

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

cout << static_cast(x);
A 3
B 2
C 3.3
D 4
E undefined
F 3.0

14. What is the value returned by the following function?

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

............

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

A True
B False

16. Multiple arguments to a function are separated by a

A commas ','
B period '.'
C semicolons ';'
D comments

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

A cstdlib
B stdlib
C iostream
D cmath
E std

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

A concate(str1, str2);
B strconcate(str1, str2);
C str1 = str2;
D str1.add(str2);
E str1 += str2;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2016 Riva Del Garda Italy September 19 23 2016 Proceedings Part 3 Lnai 9853

Authors: Bettina Berendt ,Bjorn Bringmann ,Elisa Fromont ,Gemma Garriga ,Pauli Miettinen ,Nikolaj Tatti ,Volker Tresp

1st Edition

3319461303, 978-3319461304

More Books

Students also viewed these Databases questions

Question

draw a t-s diagram of this coregeneration cycle

Answered: 1 week ago

Question

2. What is the business value of security and control?

Answered: 1 week ago