i was writing some code to test the checksum for a credit card via an algorithm known as Luhn’s algorithm and verify if it's a valid card number or not the code i wrote is the program compiled fine but when i gave an input it said floating point exception i did some reading into when a floating point exception gets invoked but there was only one case which said that it occurs when you divide by zero but my program does not do that so i want to know what other cases can occur which lead to floating point exception.
#include <stdio.h>
int main(void)
{
int a = get_int("enter your card number:");
int x = 1 ;
int z ;
int y = 0 ;
int s = 0 ;
int d,k,m,g,h;
int c ;
int f = 1;
int p = 0;
bool checksum ;
int l ;
while ((a / (10^x) )> 1)
{
c = (a/10^x) ;
z= c % 10 ;
k = 2*z ;
if (k<10)
{
d = k;
}
else if (k>10||k==10)
{
d = (k%10) ;
}
y +=d;
x+=2;
}
x=p;
while ( (a / (10 ^ x) )>1 )
{
l= a/(10^x);
m = l % 10 ;
s += m;
x+=2;
}
g= s+y;
if(g%10==0)
{
checksum = 1 ;
printf("valid");
}
else
{
checksum = 0 ;
printf("invalid");
}
}```