Concepts to Practice Arrays Passing arrays to functions Description For the prelab assignment, you will declare an array

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Concepts to Practice Arrays Passing arrays to functions Description For the prelab assignment, you will declare an array

Post by answerhappygod »

Concepts To Practice Arrays Passing Arrays To Functions Description For The Prelab Assignment You Will Declare An Array 1
Concepts To Practice Arrays Passing Arrays To Functions Description For The Prelab Assignment You Will Declare An Array 1 (63.52 KiB) Viewed 25 times
Concepts To Practice Arrays Passing Arrays To Functions Description For The Prelab Assignment You Will Declare An Array 2
Concepts To Practice Arrays Passing Arrays To Functions Description For The Prelab Assignment You Will Declare An Array 2 (44.57 KiB) Viewed 25 times
Concepts To Practice Arrays Passing Arrays To Functions Description For The Prelab Assignment You Will Declare An Array 3
Concepts To Practice Arrays Passing Arrays To Functions Description For The Prelab Assignment You Will Declare An Array 3 (45.31 KiB) Viewed 25 times
Concepts to Practice Arrays Passing arrays to functions Description For the prelab assignment, you will declare an array of integers in your main() function that has 128 elements. You will not need all 128 elements, but declaring this extra space means that you can use this array to hold a variety of data as long as you use no more than 128 elements. You should write a function to initialize an array and another function to print the contents of an array. You will use these functions by calling them from main(). You are NOT allowed to do anything in main() except: CS1050 Prelab 6 Summer 2022 . Declare variables . Print header information (like "First Array:"). Call functions that you have written. . You shoul initialize the one and only array that you declare (in main()) by calling your InitializeArray() function and print it by calling your PrintArray() function: . First, initialize the array to hold values 2,3,4,5......... 40 (inclusive). . Print out the array . Second, Initialize the array to hold values 1, 4, 7, 10, 97 (inclusive). . Print out the array Prototypes for the functions you should write You may write any functions you wish to implement this program, in addition to the following functions. However, you must implement the following functions: . vold PrintArray(int array[], int size); This function should print all of the elements of the passed-in array. The second parameter, size, tells how many valid elements there are in the array. int InitializeArray(int array], int begin, int end, int increment); This function should initialize each element of the array with values starting at "begin" and ending with "end", going up or down by "increment" steps. You will need to do this by looping through the elements of the array. This function should return a count of how many elements were initialized. Int main(void) - Of course, you need to write a main() Ⓒ. Hint Remember that arrays are passed to functions sort of similar to "pass by reference". So, if I pass an array called "myarray" to a function by using its name, this is the same as passing the address of the zeroth element of that array (&myarray[0]). This is important, because it means that a function receiving an array as an argument can make changes to the values contained in that array.
Sample Output (bold indicates something entered by the user) Lab6]$ ./a.out [dpztv@clark-r630-login-node907 First Array: Element 0= 2 Element 1 = 3 Element 24 Element 3 5 Element 4 6 Element 57 Element 68 Element 79 Element 8 = 10 Element 9 = 11 Element 10 = 12 Element 11 = 13 Element 12 = 14 Element 13 = 15 Element 14 16. Element 15 17, Element 16 18 Element 17 = 19 Element 18 20 Element 19 = 21 Element 2022 Element 21 = 23 Element 22 - 24 Element 23 = 25 Element 24 Element 25 = 26 27 Element 26 28 Element 27 = 29 Element 28 30 Element 29 31 Element 30 = 32 Element 31 = 33 Element 32 34 Element 33 = 35 Element 34 - 36 Element 35 = 37 Element 36 = 38 Element 37 = 39 Element 38 40 Second Array: Element 0-1 Element 14 Element 27 Element 3 = 10 Element 413 Element 5 16 Element 6- 19 Element 7 = 22 Element 8 25 Element 9 28 Element 1031 Element 11 = 34 Element 12-37 Element 1340 Element 14-43 Element 15 = 46 0...0
Element 26 28 Element 27 = 29 Element 28 = 30 Element 29= 31 Element 30 = 32 Element 31 = 33 Element 32 = 34 Element 3335 Element 34 = 36 Element 35= 37 Element 36 = 38 Element 37-39 Element 38 40 Second Array: Element 0 = 1 Element 1 = 4 Element 2 = 7 Element 3 = 10 Element 4 13 Element 5 = 16 Element 6 19 Element 7 = 22 " Element 8 = 25 Element 9 28 Element 10 = 31 Element 11 = 34 Element 12 = 37 Element 13 = 40 Element 14 43 Element 15 = 46 Element 16 49 Element 17 = 52 Element 1855 Element 19 = 58 Element 20 61 64 Element 21 Element 22 67 Element 23 = 70 76 Element 24 73 Element 25 Element 26 79 Element 27 82 Element 2885 Element 29 Element 30 = 91 Element 3194 88 Element 32 = 97
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply