SHARE
TWEET

Untitled

a guest Jul 23rd, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top