Why does division result in zero instead of a decimal?

前端 未结 5 636
隐瞒了意图╮
隐瞒了意图╮ 2020-11-21 05:38

Teaching myself C and finding that when I do an equation for a temp conversion it won\'t work unless I change the fraction to a decimal. ie,

tempC=(.555*(tempF

5条回答
  •  情话喂你
    2020-11-21 06:20

    5/9 is an integer expression, as such it gets truncated to 0. your compiler should warn you about this, else you should look into enabling warnings.

提交回复
热议问题