Programming Fundamentals/Functions/C++: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
Creating |
(No difference)
|
Revision as of 04:32, 19 January 2017
subroutines.cpp
#include <iostream>
using namespace std;
double calculateC(double);
void displayResult(double, double);
double getF();
int main() {
double f;
double c;
f = getF();
c = calculateC(f);
displayResult(f, c);
return 0;
}
double getF() {
double f;
cout << "Enter Fahrenheit temperature:" << endl;
cin >> f;
return f;
}
double calculateC(double f) {
double c;
c = (f - 32) * 5 / 9;
return c;
}
void displayResult(double f, double c) {
cout << f << "° Fahrenheit is " << c << "° Celsius" << endl;
}
Try It
Copy and paste the code above into one of the following free online development environments or use your own C++ compiler / interpreter / IDE.