Description
Please do not plagiarize.
Please add some comments to code
For this assignment submission, a single .c or .cpp file with the required code from the questions is all that is required.
1)
A) declare and initialize an array of twenty 32bit signed integers.
B) define a function named “even_sum”, that takes two parameters.
The first parameter should be a pointer to a 32-bit integer to pass in the array and the second should be a 32-bit integer that you will use to pass the length of the previously declared array. The function should return the sum of the array elements with even indices.
2) Modify the previous function to also set all elements at odd indices to zero.
3) Define a struct with 4 members, each member should be an unsigned int. Declare an array with 5 of the previously defined structs.
4) define a function named “zero_structs”, that takes 2 parameters. The first parameter should be a pointer to a struct of the previously defined type to pass in the array of structs, and the second should be a 32-bit integer that you will use to pass the length of the array. The function should set all members of the structs in the passed-in array to zero.
5) Define a function named “fill_structs”, which takes 3 parameters. The first parameter should be a pointer to a struct of the previously defined type to pass in the array of structs, the second should be a pointer to a 32-bit integer to pass in the array from part one, and the third should be a 32-bit integer that you will use to pass the length of the integer array. The function should set the members of the structs in the passed-in array to the elements of the 32-bit integer array that you pass in (i.e. the first struct’s members should have the first 4 values of the integer array, the second struct should have the next 4 values, etc.