Plz explain this | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
2nd Jun 2018, 11:51 AM
pubudi kaushalya
2 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
2nd Jun 2018, 12:00 PM
Jakub Belter
+ 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
2nd Jun 2018, 12:01 PM
᠌᠌Brains[Abidemi]
᠌᠌Brains[Abidemi] - avatar