CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
using namespace std;
int main() {
int i;
cin>>i;
int j=-2147483648; //j= -2^31;
cout<<((i & j)?"negative number":"positive number");
//MSB of +ve no. is 0
//for j MSB=1 remaining bits are zeroes
//1&0=0 if i is +ve returns 0
return 0;
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run