Q:

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

belongs to collection: Switch Case Basic C Programs List

0
 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;

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include<stdio.h>

main()
{
 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:

1. For Fahrenheit To Celsius

2. For Celsius To Fahrenheit

Enter Your Choice

1

Enter The Value of Fahrenheit Temperature: 142 3

Celsius Temperature: 61.666668 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Program To Print Day of Week Name Using Switch C... >>