FOR FREE MATERIALS

Farenheit to Celsius

Back to Programming

Description

The program is written to convert the temperature from Fahrenheit to Celsius. The Fahrenheit temperature is taken as input from the user. The relationship between Celsius and Fahrenheit is:

If the given Fahrenheit temperature is 100 then the Celsius temperature will be calculated:

c = (5*(100-32))/9.

   = 37.7778

Algorithm

INPUT: Fahrenheit Temperature

OUTPUT: Equivalent Celsius temperature

PROCESS:

Step 1: [Taking the input]

               Read f [Fahrenheit temperature]

Step 2: [Converting the Fahrenheit temperature to Celsius]

               Set c<-(5×(f-32))/9

               [Printing the temperature in Celsius]

               Print "The f F is c C"

Step 3: Stop.

Code

TIME COMPLEXITY:

The time complexity of this program is O(1) as it requires a constant time to execute.

SPACE COMPLEXITY:

The space complexity of this program is O(1) as it requires a constant amount of memory space to execute for any given input.