# Thread: Problem with sine function :(

1. ## Problem with sine function :(

I can use sine function, but I wanted the Program to display the number without zeros like 0.500000, it works for all number (including 0.5) except sin, cos, and tan answers, I don't get the answer and a loop seems to be unclosed..can anyone help?
x,y,z, deci_test are double
deci_chk, deci_cnt, q are int
Code:
```                        z=x*sin(y*(3.14159265/180));
deci_test=z;
q=0;
deci_cnt=0;
while (q==0)
{
deci_chk=deci_test;
if (deci_test==deci_chk)
q=1;
else
{
deci_test=deci_test*10;
deci_cnt++;
}
}
if (deci_cnt==0)
printf("%.0f",z);
else if (deci_cnt==1)
printf("%.1f",z);
else if (deci_cnt==2)
printf("%.2f",z);
else if (deci_cnt==3)
printf("%.3f",z);
else if (deci_cnt==4)
printf("%.4f",z);
else if (deci_cnt==5)
printf("%.5f",z);
else
printf("%f",z);```
if the input is 0.500000 the out put is 0.5
but if the input is sin(30) the program doesn't display any output and a loop seems to be unclosed.. :-S

2. Why not just use "%g"?

3. sorry I'm still a small beginner, can you explain a little?

4. omg that's much much better )))))))))
Thanks pretty much that helped aloooot