Program:
#include<stdio.h>
int main()
{
int a[10],i,even=0,odd=0,n;
printf("Enter no. of elements: ");
scanf("%d",&n);
printf("Enter %d numbers:\n",n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
if(a[i]%2==0)
{
even++;
}
else
{
odd++;
}
}
printf("Even numbers: %d \nOdd numbers: %d",even,odd);
return 0;
}
Output:
#include<stdio.h>
int main()
{
int a[10],i,even=0,odd=0,n;
printf("Enter no. of elements: ");
scanf("%d",&n);
printf("Enter %d numbers:\n",n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
if(a[i]%2==0)
{
even++;
}
else
{
odd++;
}
}
printf("Even numbers: %d \nOdd numbers: %d",even,odd);
return 0;
}
Output:
No comments:
Post a Comment