I've been trying to find the length of a given number using this program, however I get the following error every time I run it:
check_length.c:16:26: runtime error: division by zero
#include <cs50.h>
#include <stdio.h>
void check_length(long);
int main(void)
{
long c = get_long("Enter Number: ");
check_length(c);
}
void check_length(long w)
{
for(int i=1;i<=16;i++)
{
int scale = w/((10)^i);
if (scale<10 && scale>0)
{
int length = i+1;
printf("%i\n",length);
}
}
}