Function that returns true if the num contains a and b digits only
int check ( int num , int a , int b ) { while ( num ) { int rem = num % 10 ; num /= 10 ; if ( rem != a && rem != b ) return 0 ; } return 1 ; }