Question

Write a function that takes temperature in degrees Fahrenheit as input and returns the temperature in...

Write a function that takes temperature in degrees Fahrenheit as input and returns the temperature in degree Celsius as output. Here is the signature of the function:

double toCelsius (double)

Following is the formula to convert °F to °C:

0 0
Add a comment Improve this question Transcribed image text
Answer #1

// include required header files

#include <iostream>

using namespace std;

// create the required function.

double toCelsius(double fahrenheit)

{

    // declare the required variable

     double celsius;

     // formula

     celsius = 5.0/9 * (fahrenheit-32);

     // return the calculated result

     return celsius;

}

//main function

int main()

{

    // required variable

     double fahrenheit;

    // Display the message

     cout << "Enter Fahrenheit temperature : ";

     // take input from user

     cin >> fahrenheit;

     // call the function and display the converted temp.

     cout << "Temperature in Celsius is : "<< toCelsius(fahrenheit) <<endl;

}

Add a comment
Know the answer?
Add Answer to:
Write a function that takes temperature in degrees Fahrenheit as input and returns the temperature in...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • This program will take the user's input as a temperature in degrees Fahrenheit. The user will...

    This program will take the user's input as a temperature in degrees Fahrenheit. The user will then click a radio button indicating whether a table of temperatures, starting with the entered value, will be displayed in increments of 5 degrees F or 10 degrees F. When a submit button is clicked your code will display a HTML table of temperature values. The first column will be temperatures in degrees Fahrenheit, given in increments of 5 or 10 degrees F, depending...

  • 8.) Write a C++ program to convert temperature in degrees Fahrenheit to degrees Celsius. This is...

    8.) Write a C++ program to convert temperature in degrees Fahrenheit to degrees Celsius. This is the equation for this conversion: Celsius = 5.0/9.0 (Fahrenheit-32.0) Have your program convert and display the Celsius temperature corresponding to 98.6 degrees Fahrenheit. Your program should produce the following display (replacing the underlines with the correct values): For a Fahrenheit temperature of-_ degrees, the equivalent Celsius temperature is degrees

  • i need a python code For an exact conversion between "Fahrenheit temperature scale" and "Celsius temperature...

    i need a python code For an exact conversion between "Fahrenheit temperature scale" and "Celsius temperature scale", the following formulas can be applied. Here, F is the value in Fahrenheit and the value in Celsius: Temperature Conversions C = 5 9 (F - 32) F = (š xc) + 3 Write a Python program that uses the above formula to convert Celsius to Fahrenheit and vice versa. We ask user to input "Enter a degree: ", and then we get...

  • Task 1: Write a function that accepts temperature in degrees Fahrenheit and computes the corresponding value...

    Task 1: Write a function that accepts temperature in degrees Fahrenheit and computes the corresponding value in degrees Celsius (°C). The relation between the two is (TOF 32) Using your function convert 80 0F to Celsius (C)

  • 1. We have sever ral Fahrenheit degrees in a fi e 'Fdeg.dat and want to to read all of them into ...

    1. We have sever ral Fahrenheit degrees in a fi e 'Fdeg.dat and want to to read all of them into a list and convert the numbers to Celsius degrees. Thereafter, we want to write out a file named degrees.dat with two columns, the left with the Fahrenheit degrees and the right with the Celsius degrees. Fahrenheit degree can be converted to Celsius by: C (5.0/9) * (F-32) An example on the input file format looks like: Temperature data Fahrenheit...

  • Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The...

    Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The program should use two custom functions, f_to_c and c_to_f, to perform the conversions. Both of these functions should be defined in a custom module named temps. Custom function c_to_f should be a void function defined to take a Celsius temperature as a parameter. It should calculate and print the equivalent Fahrenheit temperature accurate to three decimal places. Custom function f_to_c should be a value-returning...

  • FOR PYTHON Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice...

    FOR PYTHON Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The program should use two custom functions, f_to_c and c_to_f, to perform the conversions. Both of these functions should be defined in a custom module named temps. Custom functionc_to_f should be a void function defined to take a Celsius temperature as a parameter. It should calculate and print the equivalent Fahrenheit temperature accurate to three decimal places. Custom function f_to_c should be a...

  • Write a program named FahrenheitToCelsius that accepts a temperature in Fahrenheit from a user and converts...

    Write a program named FahrenheitToCelsius that accepts a temperature in Fahrenheit from a user and converts it to Celsius by subtracting 32 from the Fahrenheit value and multiplying the result by 5/9. Display both values to one decimal place. For example, if 88.5 degrees is input, the output would be: 88.5 F is 31.4 C Answer in C# (Posting incomplete code i have so far that wont run correctly.) using System; using static System.Console; class FahrenheitToCelsius { static void Main()...

  • Fahrenheit scale is a temperate scale and it uses the degree Fahrenheit (symbol °F) as the...

    Fahrenheit scale is a temperate scale and it uses the degree Fahrenheit (symbol °F) as the unit. Celsius scale is another temperature scale and its symbol is °C. Fahrenheit is used by United States whereas all other countries in the world use Celsius. The formulas of conversion between Fahrenheit and Celsius are as follows: From Fahrenheit: [°C] = ([°F] − 32) × 5⁄9 From Celsius: [°F] = [°C] × 9⁄5 + 32 Write a function named convertTemp( degree, ForC )...

  • If the Celsius temperature is 20 degrees the corresponding Fahrenheit temperature is 68 degrees. When the...

    If the Celsius temperature is 20 degrees the corresponding Fahrenheit temperature is 68 degrees. When the Celsius temperature is 80, the corresponding Fahrenheit temperature is 176 degrees. Let C represent the Celsius temperature and F the Fehrenheit temperature. a) Express F as an exact linear function of C. b) Solve the equation in part a for C, thus expressing C as a function of F. c) For what temperature does F=C?

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT