Pruthvi Patel

Pruthvi Patel

  • NA
  • 129
  • 23.5k

Split an array in n elements and sum like below.

Sep 29 2016 7:06 AM
This is different than previous uploaded question please see carefully.
I have one array called ans[i].
ans[i]={1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 } //n no.of inputed element.
and i want to split in group of 3 and sum of 3-3 elements and stored it in array.Like this
res[0]= 35     //1+4+7+10+13
res[1]=40     //2+5+8+11+14
res[2]=45    //3+6+9+12+15....like this.

Answers (2)