Questions:
Write a program that has main() call a user-defined function that takes a Celsius temperature value as an argument and then returns the equivalent Fahrenheit value. The program should request the Celsius value as input from the user and display the result, as shown in the following code:
Please enter a Celsius value: 20
20 degrees Celsius is 68 degrees Fahrenheit.
For reference, here is the formula for making the conversion:
Fahrenheit = 1.8 × degrees Celsius + 32.0
Explanation:
This problem is simple and just demonstration C++ Functions. Below mention code is compiled in Visual Studio 2015 and output snap is attached.. If any problem you feel and want explanation feel free to contact.
Code:
Output:
Related Articles:
Write a program that has main() call a user-defined function that takes a Celsius temperature value as an argument and then returns the equivalent Fahrenheit value. The program should request the Celsius value as input from the user and display the result, as shown in the following code:
Please enter a Celsius value: 20
20 degrees Celsius is 68 degrees Fahrenheit.
For reference, here is the formula for making the conversion:
Fahrenheit = 1.8 × degrees Celsius + 32.0
Explanation:
This problem is simple and just demonstration C++ Functions. Below mention code is compiled in Visual Studio 2015 and output snap is attached.. If any problem you feel and want explanation feel free to contact.
Code:
/**************************************************|
/*************C++ Programs And
Projects************|
***************************************************/
#include<iostream>
using namespace std;
//function prototype
int celsiusToFahrenheitConverter(int);
void main() {
int celsius;
cout
<< "Please enter a
Celsius value == ";
cin
>> celsius;
cout
<< celsius << " degrees Celsius is
" <<
celsiusToFahrenheitConverter(celsius) << " degrees
Fahrenheit"
<< endl;
}
int celsiusToFahrenheitConverter(int
celsius) {
int Fahrenheit = 1.8 * celsius + 32.0;
return Fahrenheit;
}
Output:
Related Articles:
0 Questions:
Post a Comment