Computer Science, asked by shriyaasharma0509, 3 months ago

Using a switch case statement write a program to convert temperature from Fahrenheit to Celsius and vice versa.

for an incorrect choice on appropriate message should be displayed.
Hint: c=5/9*(f-32) and f=1.8*c+32

Answers

Answered by sricharan25
0

I don't know the answer but I am trying to say the answer

Answered by Yamini2110
0

#include<stdio.h>

int 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);

}

Similar questions