This blog is under construction

Monday, 10 June 2013

C program to convert Celsius to Fahrenheit

Write a C program to convert Celsius to Fahrenheit.

  /* celcius to fahrenheit */
  #include <stdio.h>
  int main() {
        float fahr, celsius;

        printf("Enter the value for celsius:");
        /* get a value in celsius from user */
        scanf("%f", &celsius);

        /* convert celsius to fahreneheit */
        fahr =(9.0/5.0) * celsius + 32;

        /* print the result */
        printf("%.3fc is equal to %.3fF\n", celsius, fahr);
        return 0;

  jp@jp-VirtualBox:~/$ ./a.out
  Enter the value for celsius:33
  33.000c is equal to 91.400F

See Also:

No comments:

Post a Comment