Limits/Boundaries on numbers

{
//arcsine
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;
}
else
{
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 on
brother, 1st step is putting your code in the CODE tag... -.-

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 cout << "Enter to calculate for arccosine: (The value should be between -1 and 1)
 {
//arcsine
 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; 
    }
 else 
    {
           cout << "Your choice is uncomputable in this equation. \n";
    }
 } 


and 2nd thing is tht i dont understand why you use the {} after cout o.O
Last edited on

if (num1 >= -1)


1
2
3
4
5
6
7
//result = asin (num1) * 180.00 / pi; <--move this
if(num1 >= -1 && num1 <= 1)
{
    result = asin (num1) * 180.00 / pi;//here
    cout << ....
}
...
Last edited on
That works -thank you very much, as for the {}it is just a habit of mine..still works.
Topic archived. No new replies allowed.