Write a program that accepts each element in the array from the user, and finds the following:

a. The minimum number in the array

b. The maximum number in the array

c. Average of all values in the array

d. Sum of the numbers present from index [2] to index [7]

e. Identify how many times ‘5’ was found in the array.

f. Identify all the odd numbers in the array

g. Sum of all odd numbers in the array

h. Identify even numbers in the array

i. Sum of all even numbers in the array

j. Identify count of even numbers and odd numbers in the array.

k. Identify numbers which are divisible by 2 and 5.

Answer :

motojack500

I do not have time to do all of these right now but here are functions for the first 2 in javascript

//my test array

let arr = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]

function min(arr){

 let high = arr[0]

 for(i in arr){

   if(arr[i] < high) high = arr[i]

 }

 return high

}

function max(arr){

 let high = arr[0]

 for(i in arr){

   if(arr[i] > high) high = arr[i]

 }

 return high

}

Other Questions