Setting Boundaries on Input for Numbers

jpacosm's Avatar
Newbie Member
I already turned in this code, but was trying to figure out for myself:
		cout << "Enter a degree to calculate for arcsine: (Choice should be between -1 and 1.) ";
			cin >>num1;
		result = asin (num1) * 180.00 / pi;
		if (num1 >= -1) 
			cout << "    The arcsine of " << num1 << " comes  out to be " << result << " degrees." << endl; 
			cout << "Your choice is uncomputable in this equation. \n";
I have it so there is an error if your input is greater than 1, but I cannot figure out how to do it to set if your input is lower than negative 1 at the same time- How do I set two boundaries at once?

Last edited by shabbir; 1May2011 at 09:58.. Reason: Code blocks
xpi0t0s's Avatar, Join Date: Aug 2004
Use multiple tests, so if you want to check if an input number is odd and between 32 and 45:
if ((inputNum%1) && (inputNum>=32) && (inputNum<=45))