Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this lab is due today, please help me with that. thank u so much and have a nice day! Help With Lab9 lab9 (1).pdf X

image text in transcribedimage text in transcribed

this lab is due today, please help me with that. thank u so much and have a nice day!

Help With Lab9 lab9 (1).pdf X softEdge_8wekyb3d8bbwe/TempState/Downloads/1ab9%20(1).pdf In main.cpp do the following step by step: 1. Globally define array all of integers consisting of values: 5,7,-2,811, -9,4,6, 12, and -1 in order. 2. Globally define array b[1 of integers consisting of values: 4,16,9,-2, 1, 1, -2,9, 16, and 4 in order. 3. Globally define three vectors of integers, without initial values. Call them veci, vec2, and vec3 (3 points) 4. Define the following functions on vectors. In all of the following functions pass the vector by refer- ence. HER (a) Define function void initVector (...) that receives a vector of integers as its first input, an array of integers as a second input, and an integer as its third input. The third input represents the number of elements in the input array. Initialize the input vector with the elements existing in the input array (3 points). (b) Define function void print Vector (...) that receives a vector of integers as input and prints the elements residing within that vector in the standard output. Since the input vector is not being modified by this function, define it to be constant (3 points). (C) Define function int minVector (...) that receives a vector of integers as input and re- turns the least element. Since the input vector is not being modified by this function, define it to be constant (3 points). (d) Define function int product Vector (...) that receives a vector of integers as input and returns the product of all elements within the input vector. Since the input vector is not being modified by this function, define it to be constant (3 points). (e) Define function void copyVector (...) that receives two vectors of integers as inout and copies the first vecotr into the second vector element by element, i.e., second vector becomes identical to the first one. Do not use vector traversal through loops for this purpose. Since the first input vector is not being modified by this function, define it to be constant (3 points). (1) Define function void greaterVector (...) that receives three vectors of integers as input, compares the first two vectors element by element, and puts the larger one in the third vector in the same index). Since the first two input vectors are not being modified by this function, define them to be constant (3 points). (g) Define function bool isPalindrome (...) that receives a vector of integers as input and returns true if the input vector is a palindrome. Otherwise it returns false. A sequence of items is a palindrome if it reads the same backward as forward. For example, the vector of numbers 1,2,3,2,1 and the vector of numbers 1,2,3,3,2,1 are palindromes. However, the vector of numbers 1,2,3,1 is not a palindrome. Since the input vector is not being modified by this function, define it to be constant (3 points). (h) Define function void updateLast (...) that receives a vector of integers as input along with an integer. The function is supposed to change the last item of the vector to the integer input. Do not use at() function for this purpose (3 points). elp With Lab9 e lab9 (1).pdf Edge_Baekyb3d8bbwe/TempState/Downloads/lab9%20(1).pdf - t & co. In main() function do the following step by step, using the functions defined above: (i) Print out the initial size of veci (1 points). (ii) Initialize vecl according to array a() (1 points). (iii) Print out the size of vecl after initialization according to the function defined above (1 points). (iv) Print out the elements of veci, according to the function defined above (I points). (v) Initialize vec2 according to array b [] (1 points). (vi) Print out the elements of vec2, according to the function defined above (I points). (vii) Print out the minimum element of veci (1 points). (viii) Print out the product of all elements of veci (1 points) (ix) Copy veci to vec3 according to the function defined above, and print out vec3's elements (I points) (x) Collect larger elements from vec1 and vec2 to vec 3. Next, print out vec3's elements (1 points). (xi) Check if veci is a palindrome according to the function defined above, and report the result. (xii) Check if vec2 is a palindrome according to the function defined above, and report the result. (xiii) Update the last element of vec3 to 7, according to the function defined above (1 points). The output of the program may look like the following: initial size of veci: 0 size of veel after initialization: 10 vecl content: 5, 7, -2, 8, 11, -9, 4, 6, 12, -1 vec2 content: 4, 16, 9, -2, 1, 1, -2, 9, 16, 4 minimum of veci: -9 product of veel: -15966720 copy veci to vec3: 5, 7, -2, 8, 11, -9, 4, 6, 12, -1 collect larger elements from veel and vec2 to vec 3:5, 16. 9. 8. 11. 1. 4. 9. 16. vecl is not Palindrome vec2 13 Palindrome Updating the last element of vec 3: 5, 16, 9, 8, 11, 1. 4. 9. 16.7

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_2

Step: 3

blur-text-image_3

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

Practical Neo4j

Authors: Gregory Jordan

1st Edition

1484200225, 9781484200223

More Books

Students also viewed these Databases questions

Question

Does it make clear how measurements are defined?

Answered: 1 week ago

Question

Question How are IRAs treated for state tax law purposes?

Answered: 1 week ago