ans for arr | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

ans for arr

int res = 0; for(int el : arr) { res += el;}

6th Sep 2018, 6:23 AM
chagbe Emmanuel
2 Answers
+ 4
res stores the sum of all elements in an array
6th Sep 2018, 1:54 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
+ 3
There must be some arr defined above, an int array. This will loop through each element in the array and add it to res
6th Sep 2018, 6:46 AM
Dan Walker
Dan Walker - avatar