+ 1
Are you trying to calculate a sum for each of the 3 columns?
If that's what you want, here are 2 options. Either is equally good.
Option 1: initialize each and every element in sum to 0.
Option 2: Initialize to the first 3 values from arr and have your sum loop start at index 1 instead of 0.
On a side note, avoid declaring the variable "sum" more than once in the same function. Your code declares sum as an array of int with 3 elements. Your code also declares sum as an int. Reusing the same variable name compiles fine but makes your code less understandable. The indentation is also unusual.