Advertisement
Imran1107048

Celsius <-> Fahrenheit

Oct 29th, 2020
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include<stdio.h>
  2. double celsiustofahrenheit(double c)
  3. {
  4. return (((9*c)/5)+32);
  5. }
  6. double fahrenheittocelsius(double f)
  7. {
  8. return (((f-32)*5)/9);
  9. }
  10.  
  11. int main()
  12. {
  13. char g;
  14. double c,f;
  15. scanf("%c",&g);
  16. if(g=='f' || g=='F'){
  17. scanf("%lf",&f);
  18. printf("Celsius = %.4lf\n",fahrenheittocelsius(f));
  19. }
  20. else{
  21. scanf("%lf",&c);
  22. printf("Fahrenheit = %.4lf\n",celsiustofahrenheit(c));
  23. }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement