0
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?

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Ancient Dragon
1

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.

Edited by Ancient Dragon: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.