I wrote the code for a simple problem on HackerRank where you have to count the number of digits of a number which divide the number with 0 remainder.
I used a basic while loop for testing each digit. Number of test cases are t and the number is n.
The code that I wrote is:
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
    int t;
    cin >> t;
    int count[t];
    for (int t_itr = 0; t_itr < t; t_itr++) {
        int n;
        cin >> n;
        int dig,temp=n;
        count[t_itr]=0;
        while(n>0){
            dig=n%10;
            if(temp%dig==0){
                count[t_itr]++;
            }
            n=n/10;
        }
    }
    for(int x=0;x<t;x++){
        cout<<count[x]<<endl;
    }
    return 0;
}
Input:
2
12
1012
Expected Output:
2
3
My Output:
~ no response on stdout ~
