Skip to content

Instantly share code, notes, and snippets.

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
You can’t perform that action at this time.