adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Write a program in C to count the odd or even numbers in given array.

Write a program in C to count the odd or even numbers in given array.

#include<stdio.h>
#include<conio.h>
  void main()
    {
     int i,a[10],n,even=0,odd=0;
     clrscr();
     printf("Enter a number you want to insert in array:-");
     scanf("%d",&n); 
    printf("Enter %d nos.:-",n);
     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 nos.=%d",even);
    printf("\nOdd nos.=%d",odd);
    getch();
 }


Output:-

Post a Comment

0 Comments