No. of even and odd elements from array

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:



No comments:

Post a Comment

x^y using recursion

Program: #include<stdio.h> int power(int a,int b); int main() { int x,y,ans; printf("Enter x and y:\n "); scanf(...