Skip to content

Instantly share code, notes, and snippets.

Created November 27, 2017 15:46
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Simple library for converting temperatures from Celsius to Fahrenheit and vice versa.
#include "temperature.h"
#include <math.h>
float to_fahrenheit(float celsius) {
float fahrenheit;
fahrenheit = roundf( ( (celsius * (9.00f/5.00f)) + 32.00f ) * 100.00f ) / 100.00f;
return fahrenheit;
float to_celsius(float fahrenheit) {
float celsius;
celsius = roundf( ( (fahrenheit - 32.00f) * (5.00f/9.00f) ) * 100.00f ) / 100.00f;
return celsius;
float to_fahrenheit(float);
float to_celsius(float);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment