in c++
3- Create a vector of integers and do the following:
a- Create fillVector function that uses the push_back method provided by the vector class to fill the vector with random numbers (use rand).
b- Now implement the void addNumbers(vector &data) method that adds 10 numbers to the data vector (use a for loop).
c- Create a new function void print_even(const vector& data) that prints all of the elements in the data vector that are stored at an even index (i.e. data.at(0), data.at(2), ...) . Use the at()method to access elements of a vector
We need at least 10 more requests to produce the answer.
0 / 10 have requested this problem solution
The more requests, the faster the answer.
in c++ 3- Create a vector of integers and do the following: a- Create fillVector function...
Create this c++ program. Create to classes and name their type Account and Money. Follow the instruction listed below. Please read and implement instructions very carefully Money Class Requirements - Negative amounts of Money shall be stored by making both the dollars and cents negative The Money class shall have 4 constructors * A default constructor that initializes your Money object to $0.00 A constructor that takes two integers, the first for the dollars and the second for the cents...
Consider the following program that reads a number of nonnegative integers into an array and prints the contents of the array. Complete the missing parts, add new function prototypes and function definitions, and test the program several times. Add the following to the program: Write a void function that prints the list of nonnegative integers in reverse. Write a void function that prints all the numbers stored in the list that are greater than 10. It will also print the...
MATLAB Create a row vector vC=2:3:38 that has 13 elements. Then, create the following new vectors by assigning elements of vC to the new vectors: (a) A vector (name it vCodd) that contains all the elements with odd index of vC; i.e., vCodd = 2 8 14 ... 38. (b) A vector (name it vCeven) that contains all the elements with even index of vC; i.e., vCeven = 5 11 17 ... 35. In both parts use vectors of odd...
Define a std::vector<int> variable v and add 15 random integers into that container. Use the <random> header file and the “uniform_int_distribution” to generate values between 1 and 100, inclusive. <random> is available only in C++11 and newer. If you prefer, you can use floating-point values instead of ints, in that case, look up uniform_real_distribution -- if you decide to do that, use float or double instead of int in all subsequent parts of the lab. Write a print function that...
Provide code and full projects neatly and in proper form and in the correct header and cpp files((we have to make 3 files header file , one .cpp file for function and one more main cpp file) Template Classes – Chapter 12 Write an example of a template function that can swap 2 generic elements. Create a C++ class vector using the class diagram shown in Figure 12.2. in Liangs textbook. Do not use the C++ provided header file <vector>...
C++ Question 12. Based on our Vector class which only held integers, we want to implement a class Iterator, sufficient to handle a ranged for. (You are not writing any part of the class Vector!!!) Our goal is for the following function to work properly, i.e. to double every int in the Vector v. void double(Vector& v) { for (int& val : v) { val *= 2; } } As you know, the Vector class must support the methods begin()...
7eatng that function Write a C++ program that does the following: Fill an array of 123 elements using srand) and rand) with random numbers between 150 and 667. Fill an array of 123 elements with random numbers between 150 and 667. Using a loop. Fill an array of 123 elements with random numbers between 150 and 667. Using a for loop Use a void function to fill an array of 123 elements with random numbers between 150 and 667, Possible...
Task 1 Main Function: Declare and fill an array with 1000 random integers between 1 - 1000. You will pass the array into functions that will perform operations on the array. Function 1: Create a function that will output all the integers in the array. (Make sure output is clearly formatted. Function 2: Create a Function that will sum and output all the odd numbers in the array. Function 3: Create a Function that will sum and output all the...
TASK 1: [20] • Write a little program that creates a vector array of type doubles with 10 members (0…9) • Use a for loop to store the values i^2 in the vector for each index i • Also write code to display the content of the vector• The output should be: 0, 1, 4, 9, 16, 25, 36, 49, 64, 81 • Instead of using array access, try to use push_back, pop_back, etc. also, i.e. try being dynamic. TASK...
Create a new function file and write a function s= SUM_EVEn_ ubitname(V) that takes a vector V of arbitrary length and determines the sum of the even element and assign it to s. your function calculations must do the following: * Use a loop that iterates through every element of V and adds s only even element and skips all other elements. * Contain the appropriate H1 and help text lines. * Note: A number is even, if round(number/2) is...