double celsiusToFahrenheit(double degreesC)
{
return degreesC * 9.0 / 5.0 + 32.0;
}
double fahrenheitToCelsius(double degreesF)
{
return (degreesF - 32.0) * 5.0 / 9.0;
}
Or instead of having to divide and multiply you can simply use (Celsius +32)1.8.
(C+32)1.8
Fahrenheit -32 divided by 1.8.
F-32/1.8.
CLS INPUT "Enter degrees in Celsius:";c INPUT "Enter degrees in Fahrenheit:";f a=(c*1.8)+32 b=5/9(f-32) PRINT c;"degree Celsius=" a;"degree Fahrenheit" PRINT f;"degree Fahrenheit=" b;"degree Celsius" end
Code Example:/********************************************************************************* MODULE: main.c******************************************************************************** DESCRIPTION:* Program that takes a temperature from the user on the command line, then* displays that temperature as celsius converted to Fahrenheit, and* as Fahrenheit converted to celsius.********************************************************************************/#include #define iARGS_REQUIRED 2#define iARG_EXE 0#define iARG_INPUT 1static floatfCelsiusToFahrenheit( float fCelsius );static floatfFahrenheitToCelsius( float fFahrenheit );/********************************************************************************* MAIN********************************************************************************/intmain( int iArgc, char *acpArgv[] ){ float fFahrenheit = 0.0; float fCelsius = 0.0; float fInput = 0.0; /* user didn't provide a temperature on the command line */ if(iArgc != iARGS_REQUIRED) { fprintf(stderr, "Usage: %s [temperature]\n", acpArgv[iARG_EXE]); return 0; } /* read the given temperature into the fInput variable */ sscanf(acpArgv[iARG_INPUT], "%f", &fInput); /* fInput treated as celsius and converted to Fahrenheit */ fFahrenheit = fCelsiusToFahrenheit(fInput); /* fInput treated as Fahrenheit and converted to celsius */ fCelsius = fFahrenheitToCelsius(fInput); printf( "%.2f degrees Fahrenheit is %.2f degrees celsius.\n", fInput, fCelsius ); printf( "%.2f degrees celsius is %.2f degrees Fahrenheit.\n", fInput, fFahrenheit ); return 0;}/********************************************************************************* STATIC FUNCTION: fCelsiusToFahrenheit******************************************************************************** DESCRIPTION:* Converts a celsius temperature to Fahrenheit.** PARAMETERS:* fCelsius: The temperature in celsius to convert.** RETURNS:* fCelsius converted to Fahrenheit.********************************************************************************/static floatfCelsiusToFahrenheit( float fCelsius ){ return (fCelsius * 1.8) + 32;}/********************************************************************************* STATIC FUNCTION: fFahrenheitToCelsius******************************************************************************** DESCRIPTION:* Converts a Fahrenheit temperature to celsius.** PARAMETERS:* fFahrenheit: The temperature in Fahrenheit to convert.** RETURNS:* fFahrenheit converted to celsius.********************************************************************************/static floatfFahrenheitToCelsius( float fFahrenheit ){ return (fFahrenheit - 32) / 1.8;}
Write a C program to Draw a RAINBOW and fill the suitable colors ...
Step 1. Learn the word "Fibonacci"...
you can use strstr()
CLS INPUT "Enter degrees in Celsius:";c INPUT "Enter degrees in Fahrenheit:";f a=(c*1.8)+32 b=5/9(f-32) PRINT c;"degree Celsius=" a;"degree Fahrenheit" PRINT f;"degree Fahrenheit=" b;"degree Celsius" end
59ºF = 15.0ºCUse this formula to convert degrees Fahrenheit (F) to degrees Celsius (C): (F - 32) / 1.8 = C
To convert temperature from Celsius to Fahrenheit: Multiply the Celsius temperature by 9/5. Add 32 to the result from step 1 to get the Fahrenheit temperature. Algorithm: Fahrenheit = (Celsius * 9/5) + 32.
Sure, here is a simple Python program to convert temperature from degrees Celsius to degrees Fahrenheit: celsius = float(input("Enter temperature in Celsius: ")) fahrenheit = (celsius * 9/5) + 32 print("Temperature in Fahrenheit: ", fahrenheit)
To design a flowchart for converting Fahrenheit to Celsius, you can start with an input symbol for the Fahrenheit temperature. Then, use a process symbol to apply the formula (°C = (°F - 32) x 5/9). Finally, output the result in Celsius. For converting Celsius to Fahrenheit, start with an input symbol for the Celsius temperature. Use a process symbol to apply the formula (°F = °C x 9/5 + 32). Finally, output the result in Fahrenheit.
You can use the online conversion offered by Google: in a Google search field (you may have one on your computer's browser already, otherwise go to google.com) write the number of degrees and the units ("C" or "F" or "K") then "in" and the units you want to convert to.Then hit Enter (sometimes you do not even have to do that!)__________________________________________________________= 32 + (17 x 9/5 )
algorithm step1 start step2 add 32 to Celsius temperature step3 divide 9 by 5 step4 multiply answer with sum step5 Fahrenheit temperature is obtained step6 stop
Main formula: Celsius = (Fahrenheit - 32) / 1.8Celsius = (41 -32) / 1.8Celsius = 9 / 1.8Celsius = 5°
double celsius (double fahrenheit) { return (fahrenheit - 32.) * 5. / 9.; }
echo "*** Converting between the different temperature scales ***" echo "1. Convert Celsius temperature into Fahrenheit" echo "2. Convert Fahrenheit temperatures into Celsius" echo -n "Select your choice (1-2) : " read choice if [ $choice -eq 1 ] then echo -n "Enter temperature (C) : " read tc # formula Tf=(9/5)*Tc+32 tf=$(echo "scale=2;((9/5) * $tc) + 32" |bc) echo "$tc C = $tf F" elif [ $choice -eq 2 ] then echo -n "Enter temperature (F) : " read tf # formula Tc=(5/9)*(Tf-32) tc=$(echo "scale=2;(5/9)*($tf-32)"|bc) echo "$tf = $tc" else echo "Please select 1 or 2 only" exit 1 fi
You can use the online conversion offered by Google: in a Google search field (you may have one on your computer's browser already, otherwise go to google.com) write the number of degrees and the units ("C" or "F" or "K") then "in" and the units you want to convert to.Then hit Enter (sometimes you do not even have to do that!)
Identification division. program-id.temperature11. environment division. data division. working-storage section. 77 ws-a pic 9(3)v9(2). 77 ws-b pic 9(3)v9(2). procedure division. main-para. display " enter degree temperature ". accept ws-a. compute ws-b rounded = ( 9/5 * ws-a ) + 32. display " temperature in fahrenheit celsius " ws-b. stop run..