+ 5
int arr[] = {11, 35, 62, 555, 989}; int sum = 0; for (int x = 0; x < 5; x++) { sum += arr[x]; } cout << sum << endl
guys can anyone help to solve this .... what is the output and how it works
8 Answers
+ 24
Our array consists of 5 elements. We use the for loop to count the indices of the array. x starts from 0 and goes to 4, as we start to count the indices of the array from 0. We have an integer sum which is 0 at the beginning and then we add all the values of each element of our array to the sum. So after all we will get the sum of all elements which is 1652 (if I am not mistaken).
+ 3
The Output is a error message that endl needs a semicolon haha :D
I'm jokeing :) , Output is 1652 :)
the for loop adds all numbers together and the Output is the sum of all numbers
+ 2
output:11+35+62+555+989=1652
+ 1
11+35+65+555+989=1652
sum+=arr[x] is same as sum=sum+arr[x] where the value of x in the array makes it possible to select each number from the array.
0
thanks guys...
0
here just adding all the elements of array will give you answer that is 1652
0
hahaha
0
1652