Home > Net >  cold weather meteorologists report index
cold weather meteorologists report index

Time:05-04

I'm new in c and trying to calculate "W = 33 - ( 10√v −v 10.5) * (33 - t) / 23.1", but i don't know how to use sqrt() !!

here is my code :

/*  W=33−(10√v−v 10.5)(33−t)/23.1
Where 'V' is speed in (m/s)
Where 't' is temperature in degrees Celsius: t <= 10
Where 'W' is windchill index (in degrees Celsius)
*/

#include <iostream>
#include <cmath>
using namespace std;

double meteorologistReport(double V, double t, double W);

int main() {
  double V, t, W = 0;

  cout << "Please enter wind speed (m/sec) : ";
  cin >> V;

  cout << "Please enter temperature (degrees celsius <= 10 ) : ";
  cin >> t;


  if (t > 10) {
    cout << "You entered a value above 10! Please enter a value less then or equal to 10! " << endl;
  }

  else {
    W = 33 - (10√V - V   10.5) * ( 33 - t ) / 23.1 );
    cout << "The WindChill index is : " << W << endl;
  }

  return 0;
}

Thank you.

CodePudding user response:

The square root character is not a valid math operator in C . You will have to use the sqrt function:
10.0 * sqrt(V)

Note: the square root is a floating point function, so all your values and variables should be float or double.

  •  Tags:  
  • c
  • Related