Trouble with float on C [duplicate]

1/2 does integer division, its result is 0, change either or both operand to double, e.g:

1.0/2

Leave a Comment