# Need help with converting Celsius to Fahrenheit in the code

I'm new to Arduino and trying to figure out how to convert Celsius to Fahrenheit with the parameters listed below. Do I need to create a separate file for the calculations? If so, can someone help me on how I can go about doing that?

``````#include <DHT.h>
#include <DHT_U.h>

int SENSOR = 2;
int TEMPERATURE;
int HUMIDITY;

DHT dht(SENSOR, DHT11);

void setup() {
Serial.begin(9600);
dht.begin();
pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
Serial.print("Temp: ");
Serial.print(TEMPERATURE);
Serial.println(" celsius ");
Serial.println(" ");
Serial.print("Humidity: ");
Serial.println(HUMIDITY);
delay(2000);

//Built In LED
digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(250);
}
``````
• If dht.readTemperature() and dht.readHumidity() return floating point numbers then you may want to change TEMPERATURE and HUMIDITY to "float" instead of "int". Jun 18, 2018 at 8:00

If you are using the Adafruit DHT sensor library, then you can get a Fahrenheit reading by passing `true` as an argument to `readTemperature()`. C.f. the comment in the source code. For example:

``````Serial.print("Temp: ");
Serial.println(" deg. F");
``````

Note that this library offers also the conversion functions `convertCtoF()` and `convertFtoC()`.

``````// Celsius to Fahrenheit conversion
``````Serial.print("Temp: ");