Skip to content

Instantly share code, notes, and snippets.

@MarcAstr0
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
Embed
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;
}
#ifndef LIBTEMP_LIBRARY_H
#define LIBTEMP_LIBRARY_H
float to_fahrenheit(float);
float to_celsius(float);
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment