Write a program to accept 10 number in a loop and print the count of all even number and count of all odd numbers
Answers
Answered by
0
Answer:
#include <conio.h>
int main()
{
int a[1000],i,n,even=0,odd=0;
printf("Enter size of the array : ");
scanf("%d",&n);
printf("Enter elements in array : ");
for(i=0; i<n; i++)
{
scanf("%d",&a[i]);
}
for(i=0; i<n; i++)
{
if(a[i]%2==0)
even++;
else
odd++;
}
printf("even numbers in array: %d",even);
printf("\n odd numbers in array: %d",odd);
return 0;
}
Explanation:
Enter size of the array: 5
Enter elements in array: 1
2
3
4
5
even numbers in an array: 2
odd numbers in an array: 3
Similar questions