Question
Write a simple program in the computer programming language of your choice. The program shall have two functions (methods): a main function and a helper function. The main function shall do the following: declare an array that can hold 15 integer values use a loop to put the integer values 1, 2, 3, ..., 13, 14, 15 into the array pass the array to the helper function which will return an integer value print out the value returned by the helper function The helper function shall do the following: traverse the array values found in the array, totaling the values that arc odd or a multiple of 3. return the sum of those values. The end result is that the program prints out the value 82. Notes: Use local variables rather than global variables, if supported in the implementation language. If you implement this in Python, you should use a list 1+3 + 5 + 6 + 7 + 9+11 + 12+13 + 15 = 82 Notice that 3, 9, and 15 arc not added twice. The "helper" function in this program is supposed to give the sum of selected values from the input array, specifically the odd values and multiples of 3. You will lose points if the "helper" function is tailored to the input array that is coming from main. The "helper" function should give the expected answer if the input array contained 150 random integers.
Explanation / Answer
//thanks
http://ideone.com/6OuydW