Add elements in the second half sum
else { sumsecond += arr [ i ] ; } } System . out . println ( " Sum ▁ of ▁ first ▁ half ▁ elements ▁ is ▁ " + sumfirst ) ; System . out . println ( " Sum ▁ of ▁ second ▁ half ▁ elements ▁ is ▁ " + sumsecond ) ; }