Print digits for each array element that does not divide any digit of that element | C ++ program for the above approach ; Function to find digits for each array element that doesn 't divide any digit of the that element ; Traverse the array arr [ ] ; Iterate over the range [ 2 , 9 ] ; Stores if there exists any digit in arr [ i ] which is divisible by j ; If any digit of the number is divisible by j ; If the digit j doesn 't  divide any digit of arr[i] ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void indivisibleDigits ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) { int num = 0 ; cout << arr [ i ] << " : ▁ " ; for ( int j = 2 ; j < 10 ; j ++ ) { int temp = arr [ i ] ; bool flag = true ; while ( temp > 0 ) { if ( ( temp % 10 ) != 0 && ( temp % 10 ) % j == 0 ) { flag = false ; break ; } temp /= 10 ; } if ( flag ) { cout << j << ' ▁ ' ; } } cout << endl ; } } int main ( ) { int arr [ ] = { 4162 , 1152 , 99842 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; indivisibleDigits ( arr , N ) ; return 0 ; }