Write a C program for temperature conversion The program sho
Solution
//Program and output given below:
#include <stdio.h>
int main()
 {   double t,temp=0; // t for storing user input temperature and temp for converted temperature
     char scale; //scale for storing scale char
    // prompt and accpet input temperature from user
     printf(\"Enter temperature:\");
     scanf(\"%lf\",&t);
    // prompt and accept scale from user
     printf(\"Enter temperature scale(\'C\' or \'c\' for celtigrade or \'F\' or \'f\' for Fahrenheit):\");
     scanf(\"%s\",&scale);
    //if for checking input scale and conversion.
     if(scale==\'C\'||scale==\'c\')
     {
      temp=(t-32)*5/9;
      printf(\"Temperature in Centigrade is %lf \",temp);
     }
     if(scale==\'F\'||scale==\'f\')
     {
      temp=(t*9/5)+32;
      printf(\"Temperature in Fahrenheit is %lf \",temp);
     }
     return 0;
 }
/* Output
1)First run Enter temperature:37
Enter temperature scale(\'C\' or \'c\' for celtigrade or \'F\' or \'f\' for Fahrenheit):F
Temperature in Fahrenheit is 98.600000
2)second run:
Enter temperature:98
Enter temperature scale(\'C\' or \'c\' for celtigrade or \'F\' or \'f\' for Fahrenheit):C
Temperature in Centigrade is 36.666667

