
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
Program for Fahrenheit to Kelvin conversion in C++
Given with temperature ‘n’ in Fahrenheit and the challenge is to convert the given temperature to kelvin and display it.
Example
Input 1-: 549.96 Output -: Temperature in fahrenheit 549.96 to kelvin : 561.256 Input 2-: 23.45 Output -: Temperature in fahrenheit 23.45 to kelvin : 268.4
For converting the temperature from Fahrenheit to Kelvin, there is a formula which is given below
K = 273.5 + ((F - 32.0) * (5.0/9.0))
Where, K is temperature in kelvin and F is temperature in Fahrenheit
Approach used below is as follows −
- Input temperature in a float variable let’s say Fahrenheit
- Apply the formula to convert the temperature into Kelvin
- Print kelvin
Algorithm
Start Step 1-> Declare function to convert Fahrenheit to kelvin float convert(float fahrenheit) return 273.5 + ((fahrenheit - 32.0) * (5.0/9.0)) step 2-> In main() declare and set float fahrenheit = 549.96 Call convert(fahrenheit) Stop
Example
#include<iostream> using namespace std ; //convert fahrenheit to kelvin float convert(float fahrenheit) { return 273.5 + ((fahrenheit - 32.0) * (5.0/9.0)); } int main() { float fahrenheit = 549.96; cout << "Temperature in fahrenheit "<<fahrenheit<<" to kelvin : "<<convert(fahrenheit) ; return 0; }
Output
IF WE RUN THE ABOVE CODE IT WILL GENERATE FOLLOWING OUTPUT
Temperature in fahrenheit 549.96 to kelvin : 561.256
- Related Articles
- Program for Fahrenheit to Celsius conversion in C
- Program for Celsius To Fahrenheit conversion in C++
- C# Program to perform Celsius to Fahrenheit Conversion
- Program for Binary To Decimal Conversion in C++
- Program for Decimal to Binary Conversion in C++
- Program for decimal to hexadecimal conversion in C++
- Program for octal to decimal conversion in C++
- How to Convert Temperature Units between Celsius, Kelvin and Fahrenheit in Excel?
- C Program for Decimal to Binary Conversion?
- Explain the conversion of Celsius and Fahrenheit.
- C# Program to Convert Fahrenheit to Celsius
- C++ program to convert Fahrenheit to Celsius
- Convert Fahrenheit to Celsius using C Program
- What is the relationship between the Kelvin, Celsius and Fahrenheit scales of temperature?
- C# Program to perform Currency Conversion

Advertisements