+ 2
Plz explain this
3 Answers
+ 2
Well you are initilializing the array of ints and the the variable sum. Then you iterate via loop through the array of these ints and you add them to the sum variable. Then you print it.
Also the += operator is shortcut. Consider this : x = x + variable, now this x += variable
+ 5
variable sum iterates through all the values in the array like..
sum+=arr[0]
sum+=arr[1]
sum+=arr[2]
till....4
where x is 0,1,2,3,4
so sum is the summation of each element in the array