0

How do we extract odd digit from a number????

22nd Apr 2017, 7:56 AM
Soumya Pal
Soumya Pal - avatar
7 Antworten
+ 5
@seamiki you forgot 4 ?????? 5 profit $$$$
22nd Apr 2017, 8:28 AM
Burey
Burey - avatar
+ 4
partial code do { r = n%10; if (r!=0) cout <<r<<""; n/=10; }while (n!=0); hope this helps
22nd Apr 2017, 12:20 PM
देवेंद्र महाजन (Devender)
देवेंद्र महाजन (Devender) - avatar
+ 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
22nd Apr 2017, 8:24 AM
seamiki
seamiki - avatar
+ 3
digit = no%10 (digit%2 ? even_digit : odd_digit)
22nd Apr 2017, 9:04 AM
Mayur Chaudhari
Mayur Chaudhari - avatar
+ 2
@Mayur that only gets the last digit
22nd Apr 2017, 9:07 AM
Bebida Roja
Bebida Roja - avatar
+ 2
condition is also check there
22nd Apr 2017, 9:15 AM
Mayur Chaudhari
Mayur Chaudhari - avatar
22nd Apr 2017, 8:55 AM
cybergirl
cybergirl - avatar