Discussion :: Control Structures
-
What is the output of the following program?
#include<stdio.h>
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);
}
Answer : Option C
Explanation :
Condition if(c[a]%2 == 1) forces only odd numbers to add in the sum.
Be The First To Comment