<Returning a new array created from adding odd num...
# stackoverflow
u
Returning a new array created from adding odd numbers from an array I am trying to create an array from this following array arr=[1,2,3,4,5,6,7,8,9] and it will return as sum of numbers in this way 1+3 =4 ,3+5=8,5+7=12,7+9=16. so that final answer would be newArray =[4,8,12,16]. How can I achieve it. I have done below code but it doesn't work . fun main(){ val sum = arrayOf(1,2,3,4,5,6,7,8,9) var first =0; var second=0 for (i in sum.indices){ if(sum[i]%2!=0){ first += sum[i] if (second!=0){...