I'm trying to solve a problem in hackerrank but I got a SIGFPE, Arithmetic exception error when I tried to compile my code. After a few trial and errors, I figured out that the problem lies between the part which I wrote "if(y%m==0)" because the m variable apparently contain an integer which was obtained by a modulo operation of another integer. Can somebody please explain to me why this happened and how to fix it? Here are my codes that I wrote :
#include <stdio.h>
int main()
{
int x,y,z,m,total;
scanf("%d", &x);
for(int i = 0; i<x; i++)
{
scanf("%d", &y);
for(z=y; z>0;z/=10)
{
if(z==y)
total = 0;
m=(z%10);
if(y%m==0)
{
total++;
}
}
printf("\n%d\n", total);
}
}