Question: Parallel arrays and passing arrays to functions. Generally, it is good practice when passing arrays to also pass the size of the array. However, to
Parallel arrays and passing arrays to functions. Generally, it is good practice when passing arrays to also pass the size of the array. However, to simplify things in this program, we will just assume that ALL arrays are size 5. With that, you can create a global variable at the top of your program called SIZE. Also recall that arrays behave like reference parameters in the sense that the contents on the calling side can be manipulated directly from the function side. In this program, you are to write three functions:
a. GetNumbers should take one parameter - an array of ints. The function should (using a for loop) ask the user to input five numbers - these numbers should be stored in the five slots of the array that was passed.
b. CalcSquares should take two input parameters: an array of numbers and an empty array of the same size called squares. This function calculates the square of each number in the first array and stores it in the corresponding slot in the second array.
c. DisplayValues should take two input parameters: an array of numbers and an array of squares. This function should display the values in both arrays.
Example of main():
int nums[5], squares[5];
GetNumbers(nums);
CalcSquares(nums,squares);
DisplayValues(nums,squares);

3) (30 points) Parallel arrays and passing arrays to functions. Generally, it is good practice when passing arrays to also pass the size of the array. However, to simplify things in this program, we will just assume that ALL arrays are size 5. With that, you can create a global variable at the top of your program called SIZE. Also recall that arrays behave like reference parameters in the sense that the contents on the calling side can be manipulated directly 'om the function side. In this program, you are to write three functions: a. GetNumbers should take one parameter an array of ints. The function should (using a for loop) ask the user to input ve numbers these numbers should be stored in the ve slots of the array that was passed. b. CalcSquares should take two input parameters: an array of numbers and an empty array of the same size called squares. This function calculates the square of each number in the rst array and stores it in the corresponding slot in the second array. 0. DisplayValues should take two input parameters: an array of numbers and an array of squares. This function should display the values in both arrays. Example of mainO: int nums[5] , squares[5]; GetNumbers (mums) ,- CalcSquares (mums , squares); DisplayValues (mums, squares)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
