#include <cs50.h>
#include <stdio.h>
#include <math.h>
int main(void)
{
long CardNumber = get_long ("Card number: ");
long d5;
d5 = CardNumber % pow (10, 5) / pow (10, 4);
printf("Digit 1 = %li\n", d5);
}
Is it really that the modulus operator % doesn't work with function pow or did I do something wrong?
If I replace pow (10, 5)
by 100000 number my code works. If I define pow (10, 5)
as another one variable it works too. I deal with numbers of many zeros and I don't want to count them by hand every time as well as add extra variable.
error: invalid operands to binary expression ('long' and 'double')
d5 = CardNumber % pow (10, 5) / pow (10, 4);
~~~~~~~~~~ ^ ~~~~~~~~~~~