find the output of the following code in c++
.
int sum=0;
int[]={1,2,3,4,5};
for(int i=0;i<5;i=i+2)
sum=sum+a[i];
cout<<sum;
.
correct Answer will be marked as brainiest........Plse answer fast
Answers
Answered by
2
Answer:
The answer is 8...
Explanation:
The sum of the numbers are skipping by 2
Therefore it adds the number in position 0,2,4
which is 1,3,5 respectively... after the adding position four the loop exits according to the condition <5.. hence the sum willbe
1+3+5 =8..
Hence the answer is 8
pls follow me...
Similar questions