Vidyalelo
C Programming · Q47

Control Structures

Programming · C Programming · question 47

Q47

What is the output of the following program? #include int c[10] = 1,2,3,4,5,6,7,8,9,10; main() int a, b=0; for(a=0;a<10;++a) if(c[a]%2 == 1) b+=c[a]; printf("%d", b);

A.
20
B.
24
C.
25
Answer
D.
30
E.
None of these

Answer: Option C

Solution

Answer: Option C
Solution:

Condition if(c[a]%2 == 1) forces only odd numbers to add in the sum.