Wednesday, 9 March 2016

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

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


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


Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date. If you have any Query or Question you can ask in the group, I will Try To Solve your Query and try to answers of your Questions withing 24 Hours, You can also Email me or comment below Please suggest to your Friends to join and like our page and don't forget to Subscribe. Enter your Email and click to subscribe.

Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment