Question

1. What does the below C++ statement do? vector<double> myVec(20); Group of answer choices A.It creates...

1.

What does the below C++ statement do?

vector<double> myVec(20);

Group of answer choices

A.It creates a vector object that can only store values of 10 or less.

B.It creates a vector object with a starting size of 10.

C.It creates a vector object and initializes the first element with the value 20.

D.It creates a vector object with a starting size of 20.

2.

A recursive function contains a call to itself, but is limited to 10 recursive calls unless otherwise specified by the programmer.

Group of answer choices

A.True

B.False

3.

An array of string objects that will hold four city names would be declared with which of the following statements?

Group of answer choices

A.string cityNames 5;

B.string cityNames size 4;

C.string cityNames[4];

D.string cityNames[5];

E.string cityNames(4);

4.

Which statements are a way to write an infinite loop? (Select all that apply.)

Group of answer choices

A.for (;;) { }

B.while (1) { }

C.while (&&) { }

D. while (false) { }

5.

Consider the below C++ function. If we wanted it to return the first negative value in the array, what would be a valid return statement at the location marked X?

int findFirstNegative(int array[], int length) {
    for (int i = 0; i < length; i++) {
        if (array[i] < 0)
            // X
    }
    return (-1);
}

Group of answer choices

A.return array;

B.return array[i + 1];

C.return void array;

D.return array[i];

E. return array[length];

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1)  D.It creates a vector object with a starting size of 20.
2)  B.False
3)  C.string cityNames[4];
4)  for (;;) { }
    while (1) { }
5)  D.return array[i];



Add a comment
Know the answer?
Add Answer to:
1. What does the below C++ statement do? vector<double> myVec(20); Group of answer choices A.It creates...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. If the below function countAll is called like this: countAll(10, 15); There will be an...

    1. If the below function countAll is called like this: countAll(10, 15); There will be an infinite loop. How would you fix this problem? void countAll(int num, int end) { cout << num << " "; countAll(num + 2, end); } Group of answer choices A.Change the 'cout' to print 'end' instead of 'num' B.Make the function return a string C. Change 'num + 2' to 'num + 1' D.It is not possible to fix E. Add a base case...

  • Please help with my C++ homework! 1. The following function is supposed to perform binary search....

    Please help with my C++ homework! 1. The following function is supposed to perform binary search. It has no errors and will execute correctly. int binarySearch(int array[], int size, int value) {    int first = 0,             // First array element        last = size - 1,       // Last array element        middle,                // Mid point of search        position = -1;         // Position of search value    bool found = false;        // Flag    middle = (first + last)...

  • Eclipse Java Oxygen Question 11 pts A compile-time error occurs when Group of answer choices c....

    Eclipse Java Oxygen Question 11 pts A compile-time error occurs when Group of answer choices c. there’s a syntax error in a Java statement a. the Java compiler can’t be located b. bytecodes can’t be interpreted properly c. there’s a syntax error in a Java statement Flag this Question Question 21 pts An error that lets the application run but produces the wrong results is known as a Group of answer choices d. syntax error c. logic error a. runtime...

  • Q1. Write a recursive function in C++ void printNumberedChars(string str, int i=0) { ... } which...

    Q1. Write a recursive function in C++ void printNumberedChars(string str, int i=0) { ... } which prints each character of the given string str on a new line, with each line numbered 1, 2, 3, …. For example calling the function with printNumberedChars("hello"); should output the following: 1. h 2. e 3. l 4. l 5. o Q2. Write a recursive function in C++ int sumArray(const int* arr, unsigned int size) { ... } which takes an array of integers,...

  • Does any one can show me the code in C++ ll cricket LTE 80% 16:58 Back...

    Does any one can show me the code in C++ ll cricket LTE 80% 16:58 Back P2.B MYString v1 Detail Submission Grade For this program, your MYString variables will never need to grow beyond length 20, in program 3 you will need to be allow your string that is held in the class to be able to be larger than 20 chars. So you may want to start allowing your strings to be able to grow....if you have extra time....

  • SHORT ANSWER QUESTIONS Part 1 Classes Abstraction: What is Abstraction in terms of representation? Specifically what...

    SHORT ANSWER QUESTIONS Part 1 Classes Abstraction: What is Abstraction in terms of representation? Specifically what choices does one make when creating a class that is an example of Abstraction? Encapsulation: What is encapsulation? What is information hiding? What does a public interface to a class consist of (not in the sense of actual java interfaces but what the client uses to manipulate objects of the class) What is an object of a class? What is the constructor? How do...

  • PROJECT TASKS 1. Read the problem definition below and write a C++ program that implements your...

    PROJECT TASKS 1. Read the problem definition below and write a C++ program that implements your solution. Readability of the program will be graded based on variable naming, indentation, commenting (not too little and not too much), spacing, consistency, and styling in general including choice of functions. [NOTE: the code at the end of this document does not completely meet requirements as it uses many single letter variables and has no internal documentation. You need to improve it.] 2. Compile...

  • #include <iostream> #include <iomanip> #include <vector> using namespace std; Part 1. [30 points] In this part,...

    #include <iostream> #include <iomanip> #include <vector> using namespace std; Part 1. [30 points] In this part, your program loads a vending machine serving cold drinks. You start with many foods, some are drinks. Your code loads a vending machine from foods, or, it uses water as a default drink. Create class Drink, make an array of drinks, load it and display it. Part 1 steps: [5 points] Create a class called Drink that contains information about a single drink. Provide...

  • Question 1 An array is NOT: A - Made up of different data types. B - Subscripted by integers. C -...

    Question 1 An array is NOT: A - Made up of different data types. B - Subscripted by integers. C - A consecutive group of memory chunks. D - None of the choices. Question 2 How many times is the body of the loop executed? int i=1; while(true) { cout << i; if(++i==5) break; } A - Forever B - 4 C - 5 D - 6 E - 0 Question 3 What is wrong with the following piece of...

  • Using Merge Sort: (In Java) (Please screenshot or copy your output file in the answer) In...

    Using Merge Sort: (In Java) (Please screenshot or copy your output file in the answer) In this project, we combine the concepts of Recursion and Merge Sorting. Please note that the focus of this project is on Merging and don't forget the following constraint: Programming Steps: 1) Create a class called Art that implements Comparable interface. 2) Read part of the file and use Merge Sort to sort the array of Art and then write them to a file. 3)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT