/*fahr.c (several versions) - convert Fahrenheit to Celsius.  Copyright (c)
  1998 Matthew Belmonte.*/

int main()
  {
  int fahr = 42, cels;
  cels = 5*(fahr-32)/9;
  printf("%d degrees Fahrenheit is %d degrees Celsius\n", fahr, cels);
  return 0;
  }

/*uses scanf() to get input*/
int main()
  {
  int fahr, cels;
  printf("How many degrees? ");
  scanf("%d", &fahr);
  cels = 5*(fahr-32)/9;		/*ask class: why not 5/9 * (fahr-32) here?*/
  printf("%d degrees Fahrenheit is %d degrees Celsius\n", fahr, cels);
  return 0;
  }

/*same, but with reals instead of integers*/
int main()
  {
  double fahr, cels;
  printf("How many degrees? ");
  scanf("%lf", &fahr);
  cels = 5.0*(fahr-32.0)/9.0;
  printf("%.3f degrees Fahrenheit is %.3f degrees Celsius\n", fahr, cels);
  return 0;
  }
