In this c program, we will convert temperature input by the user in celsius to Fahrenheit. We will also write the algorithm of the c program to convert temperature from Celsius to Fahrenheit. We will first find out the basic mathematics formulas and solutions to the problem. After finding out the formula and solution to our problem, we will write the algorithm and then write a program to get the desired output.
We will get the temperature in Celsius as input from the user and then I will convert temperature in Celsius using the mathematical formula. Now, after we calculate temperature in Fahrenheit, we will display it as output on the screen.
Table of Contents:
Let’s write this c program to convert temperature from Celsius to Fahrenheit. But before that, let’s just learn about the mathematical concept we are gonna use in our program.
As of now, we have taken the temperature in Celsius as input from the user and we need to convert it in Fahrenheit through a c program and display them alongside on the output screen.
Formula of the calculations:
T(°F) = T(°C) × 9/5 + 32
What are the concepts of c programming you need to learn before writing this program?
Kindly, learn these basic topics, before continuing and writing this C Program.
Here’s the algorithm of writing this C Program to convert temperature from Celsius to Fahrenheit:
- INPUT CELSIUS
- FAHRENHEIT = CELSIUS * (9/5) + 32
- DISPLAY CELSIUS
- DISPLAY FAHRENHEIT
Follow the same algorithm and let’s write the actual c program.
3. C Program to convert temperatures – Celsius to Fahrenheit
float celsius, fahrenheit;
printf("Enter temperature in celsius:\t");
fahrenheit=(celsius * 9/5) + 35;
printf("Temperature in celsius \t %f \n", celsius);
printf("Temperature in fahrenheit \t %f \n", fahrenheit);
As we have written out C Program, let’s have a look at the output. We are giving input distance as 56 in celsius and now, here are the outputs.
Here are the files of the program, you can download and try it out on your computer: