Write a program to convert Fahrenheit to Celsius degrees by passing pointers
as arguments to the function?
(Take value from the user at runtime)
#include <iostream>
using namespace std;
void farenheit2celsius(double *temperature) {
*temperature = (*temperature - 32.) * 5. / 9.;
}
int main() {
double temperature;
cout << "Enter temperature (F): ";
cin >> temperature;
farenheit2celsius(&temperature);
cout << "It is " << temperature << " C" << endl;
}
Comments
Leave a comment