if (windspeed <= -40 && windspeed <= 40) {
			windchill = calculate(temp, windspeed);
			output(temp, windspeed, windchill);
	}
	else 
		cout << "Error, please enter a number between -40 and 40 for temperature";

I need to check to make sure a number, windspeed, is between -40 and 40. Can I do this with an if statement?

if( windspeed >= -40 && windspeed <= 40) When working with negative numbers the operation is the reverse of positive numbers. That is, -50 is less than, not greater than, -40.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.