Problem:- write a c program to convert Fahrenheit to Celsius and vice versa or c program for temperature conversion using a switch or c program to convert Celsius to Fahrenheit and Fahrenheit to Celsius or c program to convert temperature from Fahrenheit to Celsius and vice versa using switch case or c program for temperature conversion using functions or flowchart to convert Celsius to Fahrenheit and vice versa or c program to convert Fahrenheit to Celsius and vice versa or c program to convert Fahrenheit to Celsius using functions
Logic:- For Converting Temperature Celsius to Fahrenheit, we are using a given Formula. We have just take a value or temperature in Celsius or Fahrenheit by the user and put the values in given formula and print the outcome given by formula on screen. Here in this problem we are given three option to the user and user have to choose any one of the first choices is Celsius To Fahrenheit, the second choice is Fahrenheit To Celsius and the Last one is Exit without testing any one of the queries.
Formula's
Celsius To Fahrenheit:-
Fahrenheit = ( Celsius * 9 / 5 ) + 32;
Fahrenheit To Celsius:-
Celsius = ( Fahrenheit - 32 ) * 5 / 9;
Suggestion:- You can also check this program in C++ Click C++ Program For Converting Temperature Celsius Into Fahrenheit
Solution:-
#include<stdio.h>
main()
{
/* Visit - www.programmingwithbasics.com*/
float a,b,centigrade, fahrenheit;
int x;
printf("1. For Fahrenheit To Celsius\n");
printf("2. For Celsius To Fahrenheit\n");
printf("\n\nEnter Your Choice\n");
scanf("%d",&x);
switch(x)
{
case 1:
printf("\nEnter The Value of Fahrenheit Temperature: ");
scanf("%f",&a);
centigrade=5*(a-32)/9;
printf("\n\nCelsius Temperature: %f ",centigrade);
break;
case 2:
printf("\nEnter The Value of Celsius Temperature: ");
scanf("%f",&b);
fahrenheit=((9*b)/5)+32;
printf("\n\nFahrenheit Temperature: %f ",fahrenheit);
break;
default:
printf("\n\nWrong Choice.....Try Again!!!\n");
}
getch();
return(0);
}
Output:-
You May Also See
1. C Program To Print Multiplication Table Using For Loop
2. C Program to Display Fibonacci Series Using While Loop
3. C Program to Find GCD of two Numbers Using For Loop
4. C Program to Find LCM of two Numbers Using while Loop
5. C Program To Insert An Element Desired or Specific Position In An Array
6. C Program For Remove Duplicates Items In An Array
7. C Program To Delete Element From Array At Desired Or Specific Position
8. C Program For Convert Octal Number to Decimal and Vice Versa Using Function
9. C Program For Convert Binary to Octal and Vice Versa Using Function
10. C Program to Display Prime Numbers Between Intervals Using Using Function
0 Comments: