0

How can write a program to count total even and odd numbers in any 10 numbers .

By using for loop in c

7th Nov 2017, 6:20 PM
HighFlyer
HighFlyer - avatar
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);
7th Nov 2017, 6:28 PM
Cool Codin
Cool Codin - avatar