Thursday, 14 February 2019

Prolog: Convert centigrade to farenheit


Formula
(C × 9/5) + 32 = 32°F

converter.pl
/*(C × 9/5) + 32 = 32°F */
c_to_f(C, F) :- F is ((C * (9 / 5)) + 32 ).


1 ?- consult(converter).
true.

2 ?- c_to_f(10, X).
X = 50.0.

3 ?- c_to_f(13, X).
X = 55.400000000000006.


Previous                                                 Next                                                 Home

No comments:

Post a Comment