Thank you for visiting Write a program in C to input a temperature in Fahrenheit convert it to Celsius and display the result Sample Output Convert temperature in Fahrenheit. This page is designed to guide you through key points and clear explanations related to the topic at hand. We aim to make your learning experience smooth, insightful, and informative. Dive in and discover the answers you're looking for!
Answer :
Here's a C++ program that takes a temperature in Fahrenheit as input, converts it to Celsius, and displays the result:
```cpp
#include
using namespace std;
int main() {
float fahrenheit, celsius;
cout << "Convert temperature in Fahrenheit to Celsius:" << endl;
cout << "Input the temperature in Fahrenheit: ";
cin >> fahrenheit;
// Convert Fahrenheit to Celsius using the formula (F - 32) * 5/9
celsius = (fahrenheit - 32) * 5 / 9;
cout << "The temperature in Fahrenheit: " << fahrenheit << endl;
cout << "The temperature in Celsius: " << celsius << endl;
return 0;
}
```
In this program, we first declare two variables: `fahrenheit` and `celsius`, both of type `float`. The `cout` statements prompt the user to input the temperature in Fahrenheit, and the `cin` statement stores the input value in the `fahrenheit` variable.
We then use the formula `(F - 32) * 5/9` to convert the temperature from Fahrenheit to Celsius, where `F` represents the temperature in Fahrenheit. The resulting Celsius value is stored in the `celsius` variable.
Finally, we use `cout` statements to display the input temperature in Fahrenheit and the converted temperature in Celsius.
When we run the program and provide an input of 95 Fahrenheit, it will output:
```
Convert temperature in Fahrenheit to Celsius:
Input the temperature in Fahrenheit: 95
The temperature in Fahrenheit: 95
The temperature in Celsius: 35
```
Learn more about Fahrenheit :
https://brainly.com/question/516840
#SPJ11
Thank you for reading the article Write a program in C to input a temperature in Fahrenheit convert it to Celsius and display the result Sample Output Convert temperature in Fahrenheit. We hope the information provided is useful and helps you understand this topic better. Feel free to explore more helpful content on our website!
- You are operating a recreational vessel less than 39 4 feet long on federally controlled waters Which of the following is a legal sound device
- Which step should a food worker complete to prevent cross contact when preparing and serving an allergen free meal A Clean and sanitize all surfaces
- For one month Siera calculated her hometown s average high temperature in degrees Fahrenheit She wants to convert that temperature from degrees Fahrenheit to degrees
Rewritten by : Jeany