Number formed by deleting digits such that sum of the digits becomes even and the number odd | C # implementation to convert a number into odd number such that digit - sum is odd ; Function to convert a number into odd number such that digit - sum is odd ; Loop to find any first two odd number such that their sum is even and number is odd ; Print the result ; Driver code
using System ; class GFG { static void converthenumber ( int n ) { String s = n . ToString ( ) ; String res = " " ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( s [ i ] == '1' s [ i ] == '3' s [ i ] == '5' s [ i ] == '7' s [ i ] == '9' ) res += s [ i ] ; if ( res . Length == 2 ) break ; } if ( res . Length == 2 ) Console . WriteLine ( res ) ; else Console . WriteLine ( - 1 ) ; } public static void Main ( String [ ] args ) { int n = 18720 ; converthenumber ( n ) ; } }