# C program to convert temperature from Fahrenheit to Celsius and Celsius to Fahrenheit.

In this C program, we are going to learn how to convert Fahrenheit to Celsius and Celsius to Fahrenheit? Here, we are implementing both of the conversations in single program only. Program will ask for the user to choose which operation, he wants?

In this choice 1 - Program will convert temperature from Fahrenheit to Celsius and choice 2 - program will convert temperature from Celsius to Fahrenheit.

## Temperature conversion program - Fahrenheit to Celsius and Celsius to Fahrenheit

﻿

```/* C Program to convert temperature from Fahrenheit to Celsius and vice versa.*/
#include <stdio.h>

int main()
{

float fh,cl;
int choice;

printf("\n1: Convert temperature from Fahrenheit to Celsius.");
printf("\n2: Convert temperature from Celsius to Fahrenheit.");
printf("\nEnter your choice (1, 2): ");
scanf("%d",&choice);

if(choice ==1){
printf("\nEnter temperature in Fahrenheit: ");
scanf("%f",&fh);
cl= (fh - 32) / 1.8;
printf("Temperature in Celsius: %.2f",cl);
}
else if(choice==2){
printf("\nEnter temperature in Celsius: ");
scanf("%f",&cl);
fh= (cl*1.8)+32;
printf("Temperature in Fahrenheit: %.2f",fh);
}
else{
printf("\nInvalid Choice !!!");
}
return 0;
}
```

Output

```First Run:
1: Convert temperature from Fahrenheit to Celsius.
2: Convert temperature from Celsius to Fahrenheit.
Enter your choice (1, 2): 1

Enter temperature in Fahrenheit: 98.6
Temperature in Celsius: 37.00

Second Run:
1: Convert temperature from Fahrenheit to Celsius.
2: Convert temperature from Celsius to Fahrenheit.
Enter your choice (1, 2): 2

Enter temperature in Celsius: 37.0
Temperature in Fahrenheit: 98.60

Third Run:
1: Convert temperature from Fahrenheit to Celsius.
2: Convert temperature from Celsius to Fahrenheit.
Enter your choice (1, 2): 3

Invalid Choice !!!
```

### Other C language basic programs

1. C program to print "Hello World!" / First C program.
This is our first program in C language; this program will print “Hello World” on the screen, it is implemented using simple method as well as using c language user defined function.
2. Program to find sum and average of two numbers.
In this program, we will read two integer numbers and find their SUM and Average and then both results will be printed on the screen.
3. C program to find cube of an integer number using two different methods.
In this C program, we are going to find cube of an integer number. Here, we will implement the program by using two methods 1) without using pow() function and 2) using pow() function.
4. C program to find quotient and remainder.
In this program, we will read divisor and dividend and then find the quotient and remainder, results will be printed on the screen.
5. Program to calculate simple interest.
In this program we will read principle, amount and rate and then calculate simple interest of borrowed principle based on give number of years and rate.
6. Program to check whether number is EVEN or ODD.
In this C program, we will read an integer number and program will check whether given integer number is EVEN or ODD.
7. Program to find largest number among three numbers.
In this C program, we will read three integer number from user and print the largest number among them.
8. C program to check whether a person is eligible for voting or not?
In this program, we are going to learn how to check that, a person is eligible for voting or not, when age is given or input through the user?
9. C program to read marks and print percentage and division.
In this C program, we are going to read marks in 3 subjects, we will find the total, percentage and print the division based on the percentage.
10. Program to find gross salary of an employee.
In this program, we will read Basic Salary of an employee and calculate HRA, DA, and Provident Fund, based on these parameters we will calculate the gross salary of the employee and print it on the screen.
11. C program to convert temperature from Fahrenheit to Celsius and vice versa.
This C program is to convert temperature from Fahrenheit to Celsius and vice versa, program will ask the choice for conversion from the user and find the converted temperature based on given input.
12. C program to calculate X^N (X to the power of N) using pow function.
This C program will read two integer number as X and Y and them calculate the X^Y (X to the power Y) and print the result on Screen.
13. C program to find the difference of two numbers.
This C program cannot be used to find the subtraction, in this program we are going to find the differences of two integer numbers. Here, we will check which largest number is and to get the difference, smallest number will be subtracted from largest number.
14. C program to print size of variables using sizeof() operator.
sizeof() is an operator in C language, which is used to print the occupied size of a variable (or size of a value), in this C program, we will print the size of different declared variables.
15. C program to demonstrate examples of escape sequences.
Escape sequences are the set of characters followed by the escape (\), in this program, we will learn to use of different escape sequence like new line character, backspace character etc.
16. C program to find area and perimeter of circle.
This c program will read radios of a circle and find their perimeter and area of a circle.
17. C program to find area of a rectangle.
This c program will read length and breadth of a rectangle and calculate its area; area of rectangle will be printed on the screen.
18. C program to calculate HCF of two numbers.
This program will read two integers and print their HCF (Highest Common Factor).
19. C program to multiply two numbers using plus operator.
This C program will read two integer numbers and calculate their multiplication (product) using plus operator, here we will not multiplication (*) operator.
20. C program to demonstrate example of global and local scope.
Basically, variables have two types of scopes, in which they can be accesses. This C program, we will demonstrate use of Global and Local scope of variables.
21. C program to demonstrate example of floor and ceil functions.
This C program will find the rounded float values using floor and ceil function, which are the library functions of math.h header file.
22. C program to read Formatted Time Once through Scanf in C Language.
In this C program we will learn how to read formatted time using scanf(), the input formatted will be “HH:MM:SS”.
23. C program to define, modify and access a global variable.
In this C program, we will learn how to declare, define, access and modify the value of Global variables in C programming language?
24. C program to convert feet to inches.
This C program will read distance in feet and convert the distance in inches. Then program will print converted feet and remaining inches on the screen.
25. C program to print value in Decimal, Octal, Hexadecimal using printf.
This C program will read an integer value using decimal format and print the values in Octal, Decimal and Hexadecimal format using printf.
26. C program to print ASCII value of entered character.
This C program will read a character from user and print its ASCII code (value) on the screen.
27. C program to print How Many Inputs are taken from Keyboard using Scanf?
Here, you will learn how to count total number of inputs using scanf(), suppose you read three different values using scanf(), it will return 3.
28. C Program to calculate Employee and Employer Provident Fund.
In this C program, we will read BASIC salary of an employee and calculate employee and employer (company) provident fund contribution.
29. C program to set buffer with specific value using memset in C - Example of memset().
This C program will demonstrate example of memset(), learn how to set specific value to a buffer (character arrays) using memset()?
30. Write a C program to evaluate the net salary of an employee given the following constraints.
Given Basic Salary, DA, HRA, TA and Other we have to calculate Net Salary of an employee where tax dedication of PF and IT using C program.
31. How to swap two numbers without using a temporary variable using C program?
C program to swap two integer numbers without using temporary variable: Here, we will learn how to swap numbers without taking help of another variable in C?

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates