Spread the post

Program to separate odd and even numbers in array

Given an array element and separate all Even and odd element. To satisfied following points. 1) All even element in front of array (starting position). 2) And even After Odd element

Look at this example.

Stack Areamainarray [0] 1 [1] 2 [2] 3 [3] 3 [4] 4 [5] 5 [6] 6 [7] 7 [8] 8 [9] 9 [10] 10size (int) 11 Outputarray [0] 10 [1] 2 [2] 8 [3] 6 [4] 4 [5] 5 [6] 3 [7] 7 [8] 3 [9] 9 [10] 1TC: O(n)

Accepted Output


Algorithm:


Time complexity of this program O(n)

C program to separate odd and even numbers in array.


Output


Final result

Stack Areamainarray [0] 10 [1] 2 [2] 8 [3] 6 [4] 4 [5] 5 [6] 3 [7] 7 [8] 3 [9] 9 [10] 1size (int) =11

Try it Yourself

Spread the post

Recommended Posts: