Question: need help with c++ please This assignment will give you practice using random numbers, functions, C-style arrays, array and vector classes, and different call passing
need help with c++ please
This assignment will give you practice using random numbers, functions, C-style arrays, array and vector classes, and different call passing mechanisms (by value, by reference using a reference, by reference using a pointer). Please name your programassign1.cpp.
Write a C++ program that will create 3 collections (arrays). The size of each array should be 10 elements. Each array will store a random number in the range of 50 - 100. Use a ranged for loop to load each array with random numbers.
| a c-style array | use the name array1 |
| an array class object | use the name array2 |
| a vector class object | use the name array3 |
After you have created and loaded the 3 arrays you will need to make copies of the three arrays. Give the copies the names array1_copy, array2_copy, and array3_copy.
Create 3 functions that will take a single integer and double it. The doubled value will be stored in the array being processed. Use loops to call the functions to double the values in the array elements.
| 1. The first function will have a return type of int and use call-by-value. | use on array1 function double1 |
| 2. The second function will have a return type of void and use call-be-reference using a reference. | use on array2 function double2 |
| 3. The third function will have a return type of void and use call-by-reference using a pointer. | use on array3 function double3 |
Create 3 functions that will take an integer array and double every element in the array. Use loops in the functions that are called to triple the values in the array elements.
| 1. The first function will have a return type of void and use call-by-reference using a c-style array. Use [ ] in the function header: void triple1( int array1[ ], int size ) | use on array1_copy function triple1 |
| 2. The second function will have a return type of void and use call-be-reference using a reference | use on array2_copy function triple2 |
| 3. The third function will have a return type of void and use call-by-reference using a pointer. | use on array3_copy function triple3 |
Here is the sequence you should follow:
1. Create the 3 arrays. Print out each array on a single line nicely formatted [hint - use the setw() stream manipulator]
2. Double the elements in the original 3 arrays using the first set of 3 functions. Print out each array on a single line nicely formatted
3. Triple the elements in the copied 3 arrays using the second set of 3 functions. Print out each array on a single line nicely formatted
Note: You may use traditional random number generation functions or use the new C++2011 more finely tuned random number generation functions. Use the new C++2011 ranged for loop instead of the traditional for loop with 3 expressions for ALL loops except for the loops to copy the arrays AND the loop in function double1 used to double all the elements in the c-style array. A ranged for loop won't work with a c-style loop passed to a function.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
