Kizspy | Question: 37
(Choose 1 answer)
pjoven low lan
Consider the following code:
int func(int a, int n){
int S = 0;
for(int i = 0; i < n; i++) {
S=S+(a[i] % 2)*a[i];
return S;
What does the above code snippet do?
A. Calculates the sum of the absolute value of all odd elements in the array a of size n.
B. Calculates the sum of all odd elements in the array a of size n.
C. Calculates the sum of all even elements in the array a of size n.
D. Calculates the sum of squares of all elements in the array a of size n.