Counting the number of digits after decimal point in real number

edited February 2016 in Beginner C/C++

//count the digits after decimal point in a real number

include <stdio.h>

include <math.h>

int main(){

double a;
int i=0;

scanf("%lf",&a);

while(1){

    a = a * 10.0;
    if(fmod(a,10.0)==0)
        break;
    i++;

}

printf("%d\n",i);

return 0;

}

Why is this not working?

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories