0
How can write a program to count total even and odd numbers in any 10 numbers .
By using for loop in c
2 Answers
+ 7
i will skip the basic structure...
int arr[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int even = 0;
int odd = 0;
for(int i = 0; i < sizeof(arr)/sizeof(arr[0]); i++) {
if (arr[i] % 2 == 0) {
even += 1;
} else {
odd += 1;
}
}
printf(even);
printf(odd);