Two math functions | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Two math functions

I am trying to convert temperature from F - C. The math is: F - 32 * (5/9) I tried that all on one line and can’t seem to get the code to run so I tried it on separate lines and using a variable for 5/9 and just outputs 0 https://code.sololearn.com/cvIL5b3B219V/?ref=app

13th Jul 2018, 8:27 PM
Chris Richard
Chris Richard - avatar
3 Answers
+ 3
Thats because 5/9 is an integer divison, which yields 0. type 5/9.0 for example to convert it to double.
13th Jul 2018, 8:48 PM
Matthias
Matthias - avatar
+ 2
cool, thank you!
13th Jul 2018, 8:50 PM
Chris Richard
Chris Richard - avatar
+ 1
check out the solutions for the "the c programming language" book, by ritchie et al.
13th Jul 2018, 9:14 PM
Bebida Roja
Bebida Roja - avatar