Simple approach: A number is said to be Even if it is completely divisible by 2. A number is said to be Odd if it is leaves 1 as remainder on dividing by 2.
#include <stdio.h>
#include<conio.h>void main(){ int array[100], i, num;
clrscr();
printf("Enter the size of an array \n");
 scanf("%d", &num);
printf("Enter the elements of the array \n"); 
for (i = 0; i < num; i++) 
{
scanf("%d", &array[i]);
}
 printf("Even numbers in the array are - ");
for (i = 0; i < num; i++)
 {
if (array[i] % 2 == 0) 
{
printf("%d \t", array[i]);
}
} 
printf("\n Odd numbers in the array are -");
for (i = 0; i < num; i++) 
{
if (array[i] % 2 != 0) 
{
printf("%d \t", array[i]);
}
} 
getch();
}
 
 
 
       
    
 
 
          
      
 
 
            
          
            
          
 
 
 
 
No comments:
Post a Comment
for more information please share like comment and subscribe