Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ex9.c --- converts Fahrenheight to Celcius and Kelvin
- 2 #include <stdio.h>
- 3 #include <stdlib.h>
- 4
- 5 void Temperatures(double fahr);
- 6 int main(void)
- 7 {
- 8 double fahr;
- 9
- 10 printf("Please enter a Fahrenheit temperature: ");
- 11 scanf("%lf", &fahr);
- 12 Temperatures(fahr);
- 13 while(scanf("%lf", &fahr) >= 1)
- 14 {
- 15 Temperatures(fahr);
- 16 }
- 17 printf("Done!\n");
- 18 return 0;
- 19 }
- 20
- 21 void Temperatures(double fahr)
- 22 {
- 23 const double cels = 5.0 / 9.0 * (fahr - 32.0);
- 24 const double kelv = cels + 273.16;
- 25
- 26 printf("Fahrenheit: %.2lf\n", fahr);
- 27 printf("Celsius: %.2lf\n", cels);
- 28 printf("Kelvin: %.2lf\n", kelv);
- 29 printf("Please enter a Fahrenheit temperature or q to quit. ");
- 30 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement