Here is a simple program which counts number of Individual digits that exactly divides given number.
#include<stdio.h>
int main()
{
long long t, val, temp, count = 0, val1;
scanf("%lld", &t);
while (t--)
{
count = 0;
scanf("%lld", &val);
val1=val;
while(val1 != 0)
{
temp = val1 % 10;
val1 = val1 / 10.0 ;
if (val % temp == 0)
{
count++;
}
}
printf("%lld", count);
}
}
It throws divide by zero exception when my input is
1
300
meaning number of test cases is 1 and value is 300. But here I am dividing it by a constant 10 so why is that throwing that exception. So what should I do now to handle here? *I even tried in cpp and faced same problem