Are you learning C programming and looking for simple programs to build your basics?
In this tutorial, you’ll learn how to write a C program to convert Celsius (Centigrade) to Fahrenheit using a standard temperature conversion formula.
Formula for Temperature Conversion
To compute Fahrenheit (°F) from Celsius (°C), use the following formula:
F = (1.8 × C) + 32
Where:
F
= temperature in FahrenheitC
= temperature in Celsius
C Program to Convert Celsius to Fahrenheit
#include <stdio.h> int main() { float celsius, fahrenheit; printf("Enter temperature in Celsius: "); scanf("%f", &celsius); fahrenheit = (1.8 * celsius) + 32; printf("Temperature in Fahrenheit: %.2f\n", fahrenheit); return 0; }
Sample Output
Enter temperature in Celsius: 25 Temperature in Fahrenheit: 77.00
Why Learn This?
This simple temperature conversion program in C teaches you:
- How to use float for decimal precision
- Taking user input
- Performing basic calculations
- Displaying formatted output
These skills are essential for beginners to build confidence in programming.
Key Concepts Covered
- Data types (
float
) printf
andscanf
usage- Arithmetic expressions in C
External Reference
Celsius to Fahrenheit Explanation – NIST – A reliable guide to temperature conversions.