Tuesday, February 17, 2015
C program to convert temperature from Fahrenheit to Celsius or Celsius to Fahrenheit
#include<stdio.h>
#include<conio.h>
void main()
{
double temp,ctemp;
int ch;
clrscr(); //to clear the screen
printf("
1.Fahrenheit to Celsius");
printf("
2.Celsius to Fahrenheit");
printf("
Enter your choice(1/2):");
scanf("%d",&ch);
if(ch==1)
{
printf("Enter Temperature in Fahrenheit:");
scanf("%lf",&temp);
ctemp=(temp-32)/1.8;
printf("
Temprature in celcius is %lf",ctemp);
}
else
if(ch==2)
{
printf("Enter Temperature in Celsius:");
scanf("%lf",&temp);
ctemp=(1.8*temp)+32;
printf("
Temperature in Fahrenheit is %lf",ctemp);
}
else
printf("
Wrong choice.....!!");
getch(); //to stop the screen
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.