+ 2

Please explain the code below in description please..

int arr[] = {11, 35, 62, 555, 989}; int sum = 0; for (int x = 0; x < 5; x++) { sum += arr[x]; } cout << sum << endl; //Outputs 1652

27th Jul 2017, 1:35 PM
Yasir Faiz Ahmed
Yasir Faiz Ahmed - avatar
2 Respuestas
+ 7
It's calculating the sum of array elements. Explanation of something similar, hope it helps: https://www.sololearn.com/Discuss/400109/?ref=app
27th Jul 2017, 1:42 PM
Shamima Yasmin
Shamima Yasmin - avatar
0
It calculates the sum of the arrays. sum=sum+arr[x] Here,it adds the current arr value to the previous sum.
14th Aug 2017, 5:03 AM
R.Gautham Ram
R.Gautham Ram - avatar