Write a C program that reads ten integers The program should
Write a C program that reads ten integers. The program should count and print on the screen total number of odd and even values among these ten inputs.
Solution
#include <stdio.h>
void main()
{
int a[10], i, n,count=0,count1=0;
printf(\"Enter the size of an array \ \");
scanf(\"%d\", &n);
printf(\"Enter the elements of the array \ \");
for (i = 0; i < n; i++)
{
scanf(\"%d\", &a[i]);
}
printf(\"Number of Even Numbers : \");
for (i = 0; i < n; i++)
{
if (a[i] % 2 == 0)
{
count++;
}
else
{
count1++;
}
}
printf(\"%d \\t\", count);
printf(\"\ Number of odd numbers :\");
printf(\"%d \\t\", count1);
}
If you want to check for 10 integers simply give the value of n as 10 or if you want to give more numbers change the value of n.
