What is the output of the following program?
#include<stdio.h> main() { int a, b =0; static int c[10]={1, 2, 3, 4, 5, 6, 7, 8, 9, 0}; for (a=0; a<10; ++a) int ((c[a]%2)==0) b+=c[a]; printf(“%d”, b); }
Given code is
for (a=0; a<10; ++a) int ((c[a]%2)==0) b+=c[a];
for loop will read each value in array.
If value will is even it is added to b
b =2+4+6+8+0 =20
Ans :20
int ((c[a]%2)==0) b+=c[a];
it should be
if((c[a]%2)==0) b+=c[a];
right ??
64.3k questions
77.9k answers
244k comments
80.0k users