Print digits for each array element that does not divide any digit of that element

Print digits for each array element that does not divide any digit of that element
Given an array arr[] consisting of N positive integers, the task for each array element arr[i] is to find all the digits from [0, 9] that does not divide any digit present in arr[i].
Examples:

Input: arr[] = {4162, 1152, 99842}Output:4162 -> 5 7 8 91152 -> 3 4 6 7 8 999842 -> 5 6 7Explanation:For arr[0] ( = 4162): None of the digits of the element 4162 are divisible by 5, 7, 8, 9.For arr[1]( = 1152): None of the digits of the element 1152 are divisible by 9, 8, 7, 6, 4, 3.For arr[2]( = 99842): None of the digits of the element 99842 are divisible by 7, 6, 5.
Input: arr[] = {2021}Output:2021 -> 3 4 5 6 7 8 9

Approach: Follow the steps below to solve the problem:Traverse the given array arr[] and perform the following steps:
Iterate over the range [2, 9] using the variable i, and if there doesn’t exist any digit in the element arr[i] that is divisible by i, then print the digit i.
Otherwise, continue for the next iteration.

Below is the implementation of the above approach:

C++

#include
using namespace std;
  

void indivisibleDigits(int arr[], int N)
{
    
    for (int i = 0; i < N; i++) {            int num = 0;            cout