C Program to Convert Temperature Celsius to Fahrenheit
Posted in: C Language

C Program to Convert Temperature Celsius to Fahrenheit

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:

  1. Concepts
  2. Algorithm
  3. Program
  4. Output
  5. Resources

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.

1. Concepts

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?

  1. scanf() function
  2. Operators
  3. printf() function

Kindly, learn these basic topics, before continuing and writing this C Program.

2. Algorithm

Here’s the algorithm of writing this C Program to convert temperature from Celsius to Fahrenheit:

  1. START
  2. INPUT CELSIUS
  3. FAHRENHEIT = CELSIUS * (9/5) + 32
  4. DISPLAY CELSIUS
  5. DISPLAY FAHRENHEIT
  6. STOP

Follow the same algorithm and let’s write the actual c program.

3. C Program to convert temperatures – Celsius to Fahrenheit

#include<stdio.h>

void main()
{
float celsius, fahrenheit;
printf("Enter temperature in celsius:\t");
scanf("%f", &celsius);

fahrenheit=(celsius * 9/5) + 35;

printf("Temperature in celsius \t %f \n", celsius);
printf("Temperature in fahrenheit \t %f \n", fahrenheit);

}

4. Output

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.

C Program to Convert Temperature Celsius to Fahrenheit

5. Resources

Here are the files of the program, you can download and try it out on your computer:

  1. Raw Code
  2. C Program File

Read next: Write a program in C to input and add two matrix