148k views
5 votes
C+ Write a program that converts degrees Fahrenheit to Celsius using the following formula. degreesC = 5(degreesF – 32)/9

Prompt the user to enter a temperature in degrees Fahrenheit.Convert the temperature to Farenheit if the Celsius is entered,or to Celsius if Farenheit is entered.Display the result in readable format.If anything other than C,c,F and f is entered,print an error mssage and stop.

User Niku
by
5.2k points

1 Answer

6 votes

Answer:

Written in C++

#include<iostream>

#include<cmath>

using namespace std;

int main()

{

float degreeC, degreeF;

cout<<"Degree Fahrenheit: ";

cin>>degreeF;

degreeC = 5 * (degreeF - 32)/9;

cout<<"Degree Celsius: "<<degreeC<<" C";

return 0;

}

Step-by-step explanation:

The question requests that input should be in degree Fahrenheit

Declare all necessary variables

float degreeC, degreeF;

Prompt user for input in degrees Fahrenheit as stated in the question

cout<<"Degree Fahrenheit: ";

Get User Input

cin>>degreeF;

Convert degree Fahrenheit to Celsius

degreeC = 5 * (degreeF - 32)/9;

Display output

cout<<"Degree Celsius: "<<degreeC<<" C";

User Inimene
by
5.8k points