0
How do we extract odd digit from a number????
7 odpowiedzi
+ 5
@seamiki
you forgot
4 ??????
5 profit $$$$
+ 4
partial code
do {
r = n%10;
if (r!=0) cout <<r<<"";
n/=10;
}while (n!=0);
hope this helps
+ 3
1 Make the number a String and evaluate each char in it.
2 Remove the char that correspnd to an odd int (ASCII table '0'=48, '1'=49, '2'=50 ecc...).
3 Convert the resulting string to an int
+ 3
digit = no%10
(digit%2 ? even_digit : odd_digit)
+ 2
@Mayur that only gets the last digit
+ 2
condition is also check there