Reference no: EM132494177
Write the following functions. Each takes an array of ints and the array length. The return types differ. You should also create a temporary main() function for testing purposes. Use the array initialisation notation to create test arrays. (Later we'll replace this with another main() that takes user input via command-line parameters.)
(a) sum() - adds up all the array elements and returns the sum, an int. (For an array containing {5, 10, 15}, sum() should return 30.)
(b) max() - returns the index of the largest element in the array. (For an array containing {10, 5, 1}, max() should return 0. For the array {3, 15, 6, 500, 9} it should return 3).
(c) reverse() - reverses the order of the array elements. It doesn't return anything. (For an array containing {1, 2, 3, 4}, reverse() should change it to {4, 3, 2, 1}.)