C Program to Convert Celsius to Fahrenheit Temperature
C program to convert Celsius to Fahrenheit temperature.
In this article, you will learn how to make a C program to convert Celsius to Fahrenheit temperature.
Example
Enter the temperature in Celsius::
7
7.000000 Celsius = 44.599998 Fahrenheit
You should have the knowledge of the following topics in c programming to understand this program:
- C Functions
- C main() Function
- C printf() Function
- C while loop
- C Data Types
Standard Formula
F = (C * 9/5) + 32
Where
F is the fahrenheit unit
C is the celsius unit
In this article, we solved this problem in four methods:
C Program to Convert Celsius to Fahrenheit Temperature
// C Program to Convert Celsius to Fahrenheit Temperature
#include <stdio.h>
int main() {
float c, f;
// c - To store the celsius
// f - To store the fahrenheit
printf("Enter the temperature in Celsius::\n");
scanf("%f", &c);
/* celsius to fahrenheit conversion formula */
f = (c * 9 / 5) + 32;
// Final Output
printf("\n%f Celsius = %f Fahrenheit\n", c, f);
return 0;
}
Output
Enter the temperature in Celsius::
7
7.000000 Celsius = 44.599998 Fahrenheit
C Program to Convert Celsius to Fahrenheit using While loop
// C Program to Convert Celsius to Fahrenheit using While loop
#include <stdio.h>
int main() {
float c, f;
int i = 1;
// c - To store the celsius
// f - To store the fahrenheit
while (i) {
printf("Enter the temperature in Celsius::\n");
scanf("%f", &c);
/* celsius to fahrenheit conversion formula */
f = (c * 9 / 5) + 32;
// Final Output
printf("\n%f Celsius = %f Fahrenheit\n", c, f);
i--;
}
return 0;
}
Enter the temperature in Celsius::
23
23.000000 Celsius = 73.400002 Fahrenheit
Explanation
In the given program, we have taken input 23
from the user then we applied arithmetic operations using the standard formula of celsius to Fahrenheit conversion on the given input.
Then this will return the whole output of this program.
You should also read these things
C++ Program to Convert Celsius to Fahrenheit
Java Program to Convert Celsius to Fahrenheit
Python Program to Convert Celsius to Fahrenheit
PHP Program to Convert Celsius to Fahrenheit
C Program to Convert Celsius to Fahrenheit using Functions
// C Program to Convert Celsius to Fahrenheit using Functions
#include <stdio.h>
// This function will convert celsius to fahrenheit
float ToFahrenheit(float c) {
return (c * 9 / 5) + 32;
}
// It's the driver function
int main() {
float c; // To store the celsius
int i = 1;
printf("Enter the temperature in Celsius::\n");
scanf("%f", &c);
// Final Output
printf("\n%f Celsius = %f Fahrenheit\n", c, ToFahrenheit(c));
return 0;
}
Output
Enter the temperature in Celsius::
36
36.000000 Celsius = 96.800003 Fahrenheit
C Program to Convert Celsius to Fahrenheit using Pointers
// C Program to Convert Celsius to Fahrenheit using Pointers
#include <stdio.h>
int main() {
float c, f;
float *ptr1, *ptr2;
// c - To store the celsius
// f - To store the fahrenheit
printf("Enter the temperature in Celsius::\n");
scanf("%f", &c);
// To get the address of `c` variable
ptr1 = &c;
// Conversion of celsius to fahrenheit
f = ((*ptr1) * 9 / 5) + 32;
// To get the address of `f` variable
ptr2 = &f;
// Final Output
printf("\n%f Celsius = %f Fahrenheit\n", *ptr1, *ptr2);
return 0;
}
Also, visit these links
C Program to Enter Marks of Five Subjects and Calculate Percentage and Grade
C++ Program to Calculate Percentage and Grade
Java Program to Calculate Grade of students
Python Program to Calculate Total Marks Percentage and Grade of a Student