In this tutorial you will learn about the C Program to Convert Celsius to Fahrenheit and its application with practical example.
C Program to convert Celsius to Fahrenheit
In this tutorial, we will learn to create a C program that will convert Celsius to Fahrenheit in C programming.
Prerequisites
Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:
- Operators in C Programming.
- Basic Input and Output function in C Programming.
- Basic C Programming.
- Arithmetic Operators in C Programming.
What are Celsius & Fahrenheit?
Celsius and Fahrenheit are the two most common scales to measure the temperature. Both the scales are having different values for the measurements of temperature. The formula for conversion is given below.
1 2 3 |
<strong>Formulae for conversion Celsius to Fahrenheit </strong>F = ((C*9)/5)+32 |
Algorithm:-
1 2 3 4 5 6 7 8 9 10 11 |
1. Declaring the variable for taking the input from the user. 2. Taking the input of temperature from the user from the user. 3. Passing that Fahrenheit to program for conversion. 4. Converting the <strong>Fahrenheit to Celsius</strong>. 5. Printing the converted values. 6. End Program. |
Program to convert Celsius to Fahrenheit.
In this program, we will first take the input from the user in Celsius. And then we will convert that input into Fahrenheit. Using the above table conversion formula and Printing the result.
With the help of the below program, we can convert Celsius to Fahrenheit.
Program Code:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
/* C Program to convert Celsius to Fahrenheit */ #include <stdio.h> int main() { //Declaring the required variables for the program. float celsius, fahrenheit; //celsius = it will hold the float value for the celsius. //fahrenheit = it will hold the float value for the fahrenheit. //Taking input the temperature from the user. printf("Enter temperature in Celsius: "); scanf("%f", &celsius); //Converting celsius to fahrenheit using conversion formula. fahrenheit = (celsius * 9 / 5) + 32; //Printing the output for the program. printf("%.2f Celsius = %.2f Fahrenheit", celsius, fahrenheit); return 0; } |
Output:-
In the above program, we have first initialized the required variable.
- Celsius and Fahrenheit = it will hold the temperature value.
Taking the input temperature from the user in Celsius.
Converting into Fahrenheit.
Printing the output of the program.