C Program To Convert Celsius To Fahrenheit And Vice Versa Using Switch Case

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

Check This:- Hacker rank solution for Strings, Classes, STL, Inheritance in C++.

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

Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date for a new post or if you have any Query you can ask there with lots of coders also suggest to your Friends to join and like our page, so we can help our community, and don't forget to Subscribe. Enter your Email and click to subscribe.

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:-

Previous Post
Next Post

post written by: Ghanendra Yadav

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.
Follow Me