Programming - Arrays - Discussion

You Are Here :: Home > C++ Language > Arrays - Discussion

 



Q.

Consider the following declaration:
int list[10];
int j;
int sum;
Which of the following correctly finds the sum of the elements of list?
(i)
sum = 0;
for(j = 0; j < 10; j++)
sum = sum + list[j];
(ii)
sum = list[0];
for(j = 1; j < 10; j++)
sum = sum + list[j];                         


A. Only (i) B. Only (ii)
C. Both (i) and (ii) D. None of these

Answer: Option B
Explaination:

 


No Explanation




Discussion

Your Comments Goes here...
NameDiscussion