Basically all I'm trying to do is run a loop that returns the value of X/Y Mod 10 where X is 1234567890123456 and Y is 10^i, so that I can get each individual digit of 1234567890123456 separated. But after i = 7 it returns 11 instead of the correct value (9). All numbers involved are of the long data type. I've tried doing it with the pow() function, and manually by just inputting the powers of ten and still get the same result.
#include <stdio.h>
#include <math.h>
long Cardno;
long Digits;
long Divider;
int main(void)
{
Cardno = 1234567890123456;
Digits = log10(Cardno) +1;
if (Digits == 13 || Digits == 15 || Digits == 16)
{
for(int i = 0; i <= Digits; i++)
{
printf("%lo\n", Cardno/10000000 % 10);
}
}
else
{
printf("INVALID\n");
}
}