Program to convert temperature from farenheit to celcius or vice versa in C

Logic:

  1. Formula for temperature conversion is:
  2. C=(F-32)*5/9
  3. F=9/5 * C +32

Algorithm

  1. Enter choice ch
  2. if (ch == 1)
  3. {
  4. printf(“enter the value of temperature in Celcius\n”);
  5. scanf(“%f”, &celcius);
  6. f = (celcius * 9 / 5) + 32;
  7. printf(“the value of temperature in fahrenheit is %f”, f);
  8. }
  9. else
  10. {
  11. printf(“enter the value of temperature in fahrenheit\n”);
  12. scanf(“%f”, &f);
  13. celcius = (f – 32) * 5 / 9;
  14. printf(“the value of temperature in celcius is %f”, celcius);
  15. }

Program

#include <stdio.h>
int main()
{
printf("*****************************************************************");
printf("\n*****************************************************************");
printf("\n** WAP to convert temp from farenheit to celcius or vice versa **");
printf("\n**                      using if else                          **");
printf("\n**                Created by Sheetal Garg                      **");
printf("\n**                Assistant Professor                          **");
printf("\n**                Phone No:9467863365                          **");
printf("\n*****************************************************************");
printf("\n*****************************************************************\n");
float celcius, f;2
int ch;
printf("enter choice");
scanf("%d", &ch);
if (ch == 1)
{
printf("enter the value of temperature in Celcius\n");
scanf("%f", &celcius);
f = (celcius * 9 / 5) + 32;
printf("the value of temperature in fahrenheit is %f", f);
}
else
{
printf("enter the value of temperature in fahrenheit\n");
scanf("%f", &f);
celcius = (f - 32) * 5 / 9;
printf("the value of temperature in celcius is %f", celcius);
}
return 0;
}

Output 1:

*****************************************************************
*****************************************************************
** WAP to convert temp from farenheit to celcius or vice versa **
**                      using if else                          **
**                Created by Sheetal Garg                      **
**                Assistant Professor                          **
**                Phone No:9467863365                          **
*****************************************************************
*****************************************************************
enter choice
1
enter the value of temperature in Celcius
100
the value of temperature in fahrenheit is 212.000000

Output 2:

*****************************************************************
*****************************************************************
** WAP to convert temp from farenheit to celcius or vice versa **
**                      using if else                          **
**                Created by Sheetal Garg                      **
**                Assistant Professor                          **
**                Phone No:9467863365                          **
*****************************************************************
*****************************************************************
enter choice 
2
enter the value of temperature in fahrenheit
212
the value of temperature in celcius is 100.000000
error: You can only copy the programs code and output from this website. You are not allowed to copy anything else.