Temperature Conversion using C Language

Program Code:

#include<stdio.h>
#include<conio.h>
int main()
{
int temp , ctemp ,ftemp;
printf("Enter 1 or 2 for conversions \n1.Celsius to Fahrenheit \n2.Fahrenheit to Celsius \n\n");
scanf("%d",&temp);
if(temp==1)
{
printf("Enter Temperature in Celsius = ");
scanf("%d",&ctemp);
ftemp = ((1.8 * ctemp) + 32);
printf("Temperature in Fahrenheit is  %d",ftemp);
}
else if(temp==2)
{
printf("Enter Temperature in Fahrenheit = ");
scanf("%d",&ftemp);
ctemp = (ftemp - 32)/1.8;
printf("Temperature in Celsius is  %d",ctemp);
}
getch();
}

OutpuT: After compile and run , output is ..

Output

1 comment:

  1. C program to convert temperature from Celsius to Fahrenheit.
    To convert celsius to fahrenheit, we will use below expression:
    F =(9/5)*C + 32;

    ReplyDelete

Please disable your ad blocker to support this website.

Our website relies on revenue from ads to keep providing free content.