This is because of integer division. 5/7
makes 0.71..
, and the integer part of this number is 0
, hence it prints 0
. To solve this problem use float
type (or double type) variables as well as constants for example try:
float f = 5.0 / 7.0;
print variable f
with format string %f