Loop to find any first two odd number such that their sum is even and number is odd
for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '1' || s . charAt ( i ) == '3' || s . charAt ( i ) == '5' || s . charAt ( i ) == '7' || s . charAt ( i ) == '9' ) res += s . charAt ( i ) ; if ( res . length ( ) == 2 ) break ; }