Code In Tech - The Ultimate World of Computer Technology

Saturday, 24 March 2012

C program to find total odd and even numbers using array

SOURCE CODE:
#include<stdio.h>
#include<conio.h>
void main()
{
 int a[15],even[15],odd[15],e=0,o=0,i;
 clrscr();
 printf("Enter 15 number:");
 for(i=0;i<15;i++)
 {
  scanf("%d",&a[i]);

  if(a[i]%2==0)
  {
   even[e]=a[i];
   e++;
  }
  else
  {
   odd[o]=a[i];
   o++;
  }
 }
 printf("\nEven no. are:");
 for(i=0;i<e;i++)
 {
  printf("\n%d",even[i]);
 }
 printf("\nOdd no. are:");
 for(i=0;i<o;i++)
 {
  printf("\n%d",odd[i]);
 }
 printf("\nTotal Even Numbers are %d",e);
 printf("\nTotal Odd Numbers are %d",o);
 getch();
}

No comments :

Post a Comment