Last active
August 20, 2017 21:12
-
-
Save mohnoor94/6998c86071e85f9b342fed3e148f27bb to your computer and use it in GitHub Desktop.
A C++ function that takes as a parameter an integer, and returns the number of odd and even digits.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // www.abukhleif.com | |
| void EvenOdd (int num, int& evens, int& odds) { | |
| evens = odds = 0; | |
| while (num != 0) { | |
| if (num % 2 == 0) | |
| evens++; | |
| else | |
| odds++; | |
| num /= 10; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment