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.

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.

The 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 temperature 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 the input distance as 56 in celsius and now, here are the outputs.

C Program to Convert Temperature Celsius to Fahrenheit
groot
groot

Leave a Reply

Your email address will not be published.