I recently had problem with making a condition in my code (which is very simple btw). And I cant figure out why this code has not the output that I wanted it to have.
Basically it is a code that gets an angle and tells you in which area of circle it will be.
And the problem is how can I put all of conditions in that if statement. Should I use &
-&&
-|
-||
-,
-
(Surely the &
is not very appropriate in this position)
#include <iostream>
using namespace std;
int main()
{
int fa, a, r;
//false angle, angle, round
cout << "Enter the Angle: ";
cin >> fa;
a = fa % 360;
cout << a;
if ((a == 0) | (a == 90) | (a == 180) | (a == 270) | (a == 360) | (a == -90) | (a == -180) | (a == -360))
cout << "Border dots." << endl;
else {
if (0 < a < 90 | -270 < a < 360) {
cout << "1st Area." << endl;
}
else if (90 < a < 180 | -180 < a < -270) {
cout << "2nd Area." << endl;
}
else if (180 < a < 270 | -90 < a < -180) {
cout << "3rd Area." << endl;
}
else if (270 < a < 360 | 0 < a < -90) {
cout << "4th Area." << endl;
}
else
cout << "Wrong number!" << endl;
}
r = fa / 360;
cout << "It is " << r << " round(s) and " << a << " Angle" << endl;
}
//17/05/2020
And sorry if I had difficulties in saying my problem.Because I don't know much about math and code phrases