Computer Science, asked by likhith7534, 11 months ago

Write a prolog program that convert temperature from celsius to fahrenheit

Answers

Answered by faridkhann
5

Explanation:

We talked about:

=, ==, \=, \==, is, =:=, =\=

number/1, integer/1,float/1

Try the following queries:

?- X =a.

?- X ==a.

?- X \=a.

?- b \= a.

?- X \== a.

?- b \== a.

?- X is 1+2.

?- X = 1+2.

?- 3*5 =:= 3+12.

Notation: number/1 (for example) means that the predicate's name (the functor) is 'number' and it has 1 argument

3. Arithmentic example

-------------------------

Here are the formulae for converting between degrees Fahrenheit and degrees Celsius:

DegreesF = (9 / 5 * DegreesC) + 32

DegreesC = 5 / 9 * (DegreesF - 32)

Write two Prolog rules: one called c2f(C, F) to convert from Celsius to Fahrenheit and one called f2c(F, C) to convert from Fahrenheit to Celsius.

Make sure your rules work exactly as shown for the following queries:

?- c2f(20, F).

F = 68

?- f2c(98.6, C).

C = 37

Write a Prolog rule called convert(C, F) that first checks which temperature (C or F) is given, and then does the appropriate conversion. That is, when C is given, convert(C, F) uses c2f(C, F). When F is given it uses f2c(F, C).

Make sure your rule works exactly as shown for the following queries:

?- convert(20, F).

F = 68

?- convert(C, 98.6).

C = 37

Answered by Anonymous
9

Answer:

here is ur answer mate....!!

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 ).

Explanation:

plzz mark it as brainliest

Similar questions