Howdy, Stranger!

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

Categories

Counting the number of digits after decimal point in real number

jarvis38jarvis38 Member Posts: 3
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.