Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

cold weather meteorologists report index

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading