**Separate even and odd numbers in array **is simple program using array.

In this tutorial we are going to learn even and odd numbers, separate even and odd numbers in array, C program to separate even and odd numbers from an array.

**Even numbers definition**

The numbers which are divisible by 2.

The numbers 2, 4, 6 … are even numbers

**Odd numbers definition**

The numbers which are divisible by 2 gives the fraction result.

The numbers 3, 6, 9, … are Odd numbers.

**Logic to separate even and odd numbers in array**

First we take a numbers from user. Next we check number is even if even then print number in even numbers and if number is odd print number in odd numbers

**Concept know need to know from c**

1. Conditional statement in c

2. Looping in c

3. Array in c

**Algorithm to separate even and odd number in array**

1. Start

2. Take input numbers from user

3. Traverse array from start to end

4. If array value is even then print even numbers

5. If array value is odd then print odd numbers

6. End

## C program to separate even and odd numbers from an array

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
#include<stdio.h> main() { int i,size; printf("Enter size of array\n"); scanf("%d",&size); int a[size]; printf("Enter numbers to separate even and odd\n"); for(i=0;i<size;i++) { scanf("%d",&a[i]); } printf("Even numbers are:\n"); for(i=0;i<size;i++) { if(a[i]>=0) { if(a[i]%2==0) { printf("%d\n",a[i]); } } } printf("Odd numbers are:\n"); for(i=0;i<size;i++) { if(a[i]>=0) { if(a[i]%2==1) { printf("%d\n",a[i]); } } } } |

**Output :**

**Explanation :**

**1. In program to separate even and odd number in array**

**2. We take a total number user want to enter.**

**3**. **Example** :- size = 5

**4. we take a input numbers in array a.**

Example :- a [5] = 1, 2,3,4,5

**5. Next traverse the array a and check number is even is true we print even number**

**6. We find even number by using formula**

a[i]%2==0

=> Even numbers are

2 , 4

**7. Next again traverse the array a and check number is odd is true we print odd number**

**8. We find odd number by using formula**

a[i]%2==1

=> Odd numbers are

1, 3, 5

## Leave a Reply