QuestionQuestion

1. Use a C++ vector to do the following:
a. Create a vector of doubles.
b. Add 3.1, 3.4, and 3.5 in that order to the vector.
c. Insert 3.43 between elements 3.4 and 3.5
d. Erase the element with a value of 3.4
e. Write a snippet to print the elements of the vector.

2. In the space below, create a dynamic (using new) 2d array of characters of 4 rows, and 3 columns. Initialize all elements to the ‘-‘ character, and print it to the console.

3. Properly De-allocate the 2D array you created in the previous step.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

1. Use a C++ vector to do the following:

a. Create a vector of doubles.
std::vector<double> v;

b. Add 3.1, 3.4, and 3.5 in that order to the vector.
v.push_back(3.1);
v.push_back(3.4);
v.push_back(3.5);

c. Insert 3.43 between elements 3.4 and 3.5
std::vector<double>::iterator it;
it = v.begin();

while (it != v.end())
{
if (*it == 3.5)
{
break;
}
++it;
}

v.insert(it, 3.43);...
$55.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Visual Basic Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats