Smallest even digits number not less than N | CPP program to print the smallest integer not less than N with all even digits ; function to check if all digits are even of a given number ; iterate for all digits ; if ( ( n % 10 ) % 2 ) if digit is odd ; all digits are even ; function to return the smallest number with all digits even ; iterate till we find a number with all digits even ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int check_digits ( int n ) { while ( n ) { return 0 ; n /= 10 ; } return 1 ; } int smallest_number ( int n ) { for ( int i = n ; ; i ++ ) if ( check_digits ( i ) ) return i ; } int main ( ) { int N = 2397 ; cout << smallest_number ( N ) ; return 0 ; }