This blog is under construction

Monday, 10 June 2013

C program to convert Fahrenheit to Celsius

Write a C program to convert Fahrenheit to Celsius.



  /* C program to convert Fahrenheit to Celsius */
  #include <stdio.h>
  int main() {
        float fahr, celsius;

        printf("Enter ur input for fahrenheit:");
        /* get Fahrenheit value from user */
        scanf("%f", &fahr);

        /* convert Fahrenheit to Celsius */
        celsius = 5 * (fahr - 32) / 9;

        /* print the output */
        printf("%.2fF is equal to %.2fC\n", fahr, celsius);
        return 0;
  }



  Output:
  jp@jp-VirtualBox:~/$ ./a.out
  Enter ur input for fahrenheit:91.4
  91.40F is equal to 33.00C





See Also:

No comments:

Post a Comment