filmov
tv
Count all the odd and even elements from an Array using C Programming Language. #cprogramming

Показать описание
Count all the odd and even numbers/elements from an Array using C Programming Language. #cprogramming
Problem statement
Count number of even and odd elements in an array
Input
array size = 5
Elements = { 10, 2, 3, 7, 12}
Output
Odd numbers count = 3 (i.e. 10,2,12)
Even numbers count = 2 (i.e. 3,7)
Input
array size = 4
Elements = {12, 4, 0, 8}
Output
Odd numbers count = 0
Even numbers count = 4 (i.e. 12,4,0,8)
Procedure
1.Declare two integer variables to store odd and even numbers count and initialize them to zero.
int odd_count = 0, even_count = 0;
2.Loop through each element of an array and check whether its odd or even
Regards,
Md. Ahsan Arif
University of Scholars
Problem statement
Count number of even and odd elements in an array
Input
array size = 5
Elements = { 10, 2, 3, 7, 12}
Output
Odd numbers count = 3 (i.e. 10,2,12)
Even numbers count = 2 (i.e. 3,7)
Input
array size = 4
Elements = {12, 4, 0, 8}
Output
Odd numbers count = 0
Even numbers count = 4 (i.e. 12,4,0,8)
Procedure
1.Declare two integer variables to store odd and even numbers count and initialize them to zero.
int odd_count = 0, even_count = 0;
2.Loop through each element of an array and check whether its odd or even
Regards,
Md. Ahsan Arif
University of Scholars