- Print Even And Odd Numbers In C
- C Program To Find Odd Or Even Using Array
- C Program To Print Even And Odd Numbers
Print Even And Odd Numbers In C
FilternoneOutput:Original Array: 3 6 12 1 5 8Modified Array: 6 3 12 1 8 5Time Complexity: O(n).Auxiliary Space: O(1).This article is contributed. If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
C Program To Find Odd Or Even Using Array
Initially, variables nodd and neven, the counts for odd and even digits, respectively, are initialized to zero. Then a while loop is used to count the odd and even digits. In each iteration of this loop, the least significant digit of number num is first determined in variable digit,then the appropriate counter is incremented using an if-else statement and the least significant digit is removed from number num. The loop is executed as long as the value of num is greater than zero, i. E., all digits in num are not processed.
C Program To Print Even And Odd Numbers
Finally, the values of nodd and never are printed.#include void mainint nodd,neven,num,digit.