Introduction
In this blog, we will discuss the solution to the problem of converting Celsius to Fahrenheit. We will code the solution to this problem in C language. But before discussing the solution to this problem, we should first try to understand the context of Fahrenheit and Celsius. After that, we will look at the conversion of Celsius to Fahrenheit.

As we all know, temperature measures the degree of hotness and coldness. Celsius and Fahrenheit are both units of temperature used to measure the temperature. Celsius is also known as centigrade, and most countries use it. On the other hand, Fahrenheit is majorly used by the United States. Celsius is represented by °C, and Fahrenheit is represented by °F. Now, we should look at the formula of conversion from Celsius to Fahrenheit.

Sample Examples
Example 1:
Input:
C (Temperature in Celsius) = 10
Output
50 Fahrenheit
Explanation
(9/5) * 10 + 32 = 18 + 32 = 50You can also read about dynamic array in c and C Static Function.
Example 2:
Input:
C (Temperature in Celsius) = 3
Output:
37.4 Fahrenheit
Explanation
(9/5) * 3 + 32 = 27/5 + 32 = 5.4 + 32 = 37.4
Also see, Binary to Hex Converter, And Tribonacci Series
Approach
The approach to this problem is straightforward:
- We will first take the input in the form of float value from the user, and then we will pass that input to the formula stated above.
- We will store the result of the formula in another float variable.
- After that, we will print that output.
Implementation in C
// C Program to Convert Celsius to Fahrenheit
#include <stdio.h>
int main() {
float Celsius, Fahrenheit;
scanf("%f", &Celsius);
/* Formula for conversion from Celsius to Fahrenheit */
Fahrenheit = (Celsius * 9 / 5) + 32;
printf("%0.2f degrees in Celsius is equal to %0.2f degrees in Fahrenheit\n", Celsius, Fahrenheit);
return 0;
}
Output:
Input: Celsius = 2
Output: 2.00 degrees in Celsius is equal to 35.60 degrees in Fahrenheit
For better practice, you can implement it on the Online compiler.
Complexity Analysis
Time Complexity: O(1)
Since we are not using any loop and there are no iterations, we are doing a constant amount of work to get the answer; the time complexity is O(1).
Space Complexity: O(1)
Since no extra space was used.
Also see, Short int in C Programming



