Here is code in C++.
#include <bits/stdc++.h>
using namespace std;
// function to get input from user.
// here parameters are passed by reference
void get_inp(double &V, double &T)
{
cout << "Enter the wind speed in miles per hour: ";
cin >> V;
cout << "Enter the temperature in degrees Fahrenheit: ";
cin >> T;
}
//function to Calculate and return windChill factor.
double windChill(double &V, double &T)
{
double factor = 35.74 + (0.6215 * T) - (35.75 * V * 0.16) + (0.4275 * T * V * 0.16);
return factor;
}
// main function
int main()
{
//declare variables to store temperature and wind speed
double V, T;
// calling get_inp() to get input from user
get_inp(V, T);
/* calling w_c_fact() to Calculate windChill factor and
assign it to variable "w_c_fact".*/
double w_c_fact = windChill(V, T);
//printing the output
cout <<"The windchill factor "<<w_c_fact<<endl;
return 0;
}
Explanation:
Create two variables "V" & "T" to store the wind speed and temperature.In the function get_inp(), these variables are passed by reference and ask user to give input. Value of Wind speed and temperature are assigned to V & T respectively. then pass these value to function windChill() to Calculate the wind chill factor according to the given equation.This function will return the factor after calculation and assigned to "w_c_fact" variable.Print this factor.
Output:
Enter the wind speed in miles per hour: 37.5
Enter the temperature in degrees Fahrenheit: 110.2
The windchill factor 172.392