hey i am a complete newbie to c.
I am having this problem with floating points and the output is producing really wired results
I'm using gcc to compile it
the above code is to print a table of square roots in a sort of tabled layout.Code:float i=0.0; for(;i<=20.0;i+=0.1) { if(i==0.0 || ((int)(i*10))%10==0) { printf("\n"); printf("%5.1f ",i); } printf("%5.2f ",sqrt(i)); }
when we start it prints 0.0 and print the list of sqrt from 0.1 to 0.9
when 1.0 it again goes to a new line prints 1.0 as well as the sqrts from 1.0 to 1.9
but it creates a problem in 3.0 in my machine for some reason. Please try it out.
It's really strange
Regards