Question

In: Computer Science

{4, 6, 12, 15, 19, 23, 24}   Write one statement to print out (cout) the first...

{4, 6, 12, 15, 19, 23, 24}  

Write one statement to print out (cout) the first character and the last character of the vector you initialized

Write one statement to insert an integer 9 to myvec between numbers 6 and 12.

in c++

Solutions

Expert Solution

PROGRAM :

#include <iostream>

// <bits/stdc++.h> for STL libraries

#include <bits/stdc++.h>

using namespace std;

int main() {

// initialising vector

vector<int> vect{4, 6, 12, 15, 19, 23, 24} ;

// vector.front() and vector.back() returns first and last element of vector respectively

cout << "First and last element : " << vect.front() << " and " << vect.back() << "\n";

// 9 is to be inserted between 6 and 12 ,thus the index to be inserted is 2

// vector.insert(position,value) inserts the value ate the specified position

vect.insert(vect.begin() + 2 ,9);

for (int x : vect)

cout << x << " ";

cout << "\n";

return 0;

}

OUTPUT:


Related Solutions

A B C 8 24 19 12 16 28 22 22 24 15 14 31 18...
A B C 8 24 19 12 16 28 22 22 24 15 14 31 18 20 19 9 32 Test at the 5% level of significance to see if the means are all the same. 1. What is the null and alternate hypotheses? 2. What is the p-value? 3. Decide if you reject or accept (fail to reject) your null hypothesis. 4. Decide if you reject or accept (fail to reject) your claim.
Find the 5 number summary for the data shown 12 15 20 21 23 24 46...
Find the 5 number summary for the data shown 12 15 20 21 23 24 46 47 55 65 67 68 78 82 86 92 5 number summary: { , , , ,  } IQR= ? The 1.5XIQR1.5XIQR rule states that values between ? and ? are likely not outliers.
5. Write a C++ statement or statements that will:       Print the first two digits and the  last...
5. Write a C++ statement or statements that will:       Print the first two digits and the  last two digits of any 4 digit number stored in an integer variable n.         For example, given int n = 5623, print 56    23. 6. Write  C++ statements that will align the following three lines as printed in two 20 character columns. Name                                                 Years President Abraham Lincoln                                 1860-1865 Thomas Jefferson                               1801-1809 7.  Write a C++ statement or statements that will Output if a string has a length greater than 10, equal...
For the stress data given below with the nearest error of 1: 27-17-11-24-36-13-29-22-18 23-30-12-46-17-32-48-11-18 18-32-26-24-38-24-15-13-13 18-21-27-20-16-15-37-19-19...
For the stress data given below with the nearest error of 1: 27-17-11-24-36-13-29-22-18 23-30-12-46-17-32-48-11-18 18-32-26-24-38-24-15-13-13 18-21-27-20-16-15-37-19-19 a) Construct a frequency distribution table. b) Construct the three types of statistical graphs. c) Determine the (1) Mean, (2) Median, (3) Mode, (4) Range, Variance, and (6) Standard Deviation.
For the following data set, 5, 9, 12, 15, 19, 21, 22, 22, 24, 26, 27,...
For the following data set, 5, 9, 12, 15, 19, 21, 22, 22, 24, 26, 27, 27, 31, 33, 33, 34, 37, 38, 60, 70 a) Find the quartiles Q1 Q2 Q3 b) Find the five number summary c) Find the interquartile range (IQR) IQR = d) Find the lower limit LL = e) Find the upper limit UL = f) Identify the potential outliers (Separate each outlier with a comma. Write NPO if there is no potential outlier) The...
Write in javaScript: User input 5 words in one input, and print out the longest word.
Write in javaScript: User input 5 words in one input, and print out the longest word.
Given the following data X 12 5 6 8 11 23 14 16 15 5 Y...
Given the following data X 12 5 6 8 11 23 14 16 15 5 Y 6 10 6 5 2 4 20 5 6 10 a. Is there a linear correlation between X and Y? Explain your answer. b. What is the regression question? c. If x value is 37, what is the y value?
Consider the following data set: {4, 7, 11, 12, 18, 19, 20, 22, 23, 25} Answer...
Consider the following data set: {4, 7, 11, 12, 18, 19, 20, 22, 23, 25} Answer the following questions. If necessary, round your answers to four decimal places. (a) Find the sample median of the data set. (b) How much can you increase the smallest value from the data set without getting the value of the sample median changed? (Enter NA if there is no limit to the amount.) (c) How much can you decrease the largest value from the...
Sort 101, 55, 64, 23, 12, 09, 45, 32, 19, 65, 89 using Quick sort. Write...
Sort 101, 55, 64, 23, 12, 09, 45, 32, 19, 65, 89 using Quick sort. Write the algorithm. Please show steps.
For the following exercises, write an explicit formula for each sequence. 4, 7, 12, 19, 28, …
For the following exercises, write an explicit formula for each sequence. 4, 7, 12, 19, 28, …
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT