Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #include <stdlib.h>
  4.  
  5. int main() {
  6.     double temp, C, F;
  7.     char c;
  8.     printf(" Input temperature and unit respectively, enter f if unit is fahrenheit and c if celsius:\n");
  9.     scanf("%lf %c", & temp, & c);
  10.     if (c == 'f') {
  11.         C = (1. / 9.) * (5 * temp - 160);
  12.         printf("The temperature is %lf celsius ", c);
  13.     } else if (c == 'c') {
  14.         F = (1. / 5.) * (9. * temp + 160);
  15.         printf("The temperature is %lf fahrenheit ", F);
  16.     } else printf("Invalid input");
  17.  
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement