Celsius To Fahrenheit and back In C

Q. Changing  Celsius to Fahrenheit and back in C  by simple program.

#include<stdio.h>
#include<conio.h>
void main()
{
int option;
float c,f;
clrscr();
printf(“Enter c for celsius to fahrenheit, f for the reverse\n”);
option=getch();
switch(option)
{
case ‘c’:
case ‘C’:
printf(“Enter value in celsius\n”);
scanf(“%f”,&c);
f=(c*9)/5 + 32;
printf(“%0.2f celsius is %0.2f fahrenheit\n”,c,f);
break;
case ‘f’:
case ‘F’:
printf(“Enter Value in farenheit\n”);
scanf(“%f”,&f);
c=((f-32)*5)/9;
printf(“%0.2f farenheit is %0.2f celsius\n”,f,c);
break;
default:printf(“Invalid choice”);
}
getch();
}

After Running Program 🙂

,

 

Leave a Reply