+ 1
Input a number and check whether it is positive or negative??
Pls answer it
10 Respuestas
+ 2
Include the header files
int main()
{
float a;
cin>>a;
if(a>0)
{cout<<"The no. u entered is positive";}
else if(a==0)
{cout<<"0 is an unique no.";}
else
{cout<<"The no. u entered is negative";}
}
+ 1
Pls check the corrections
+ 1
Why it is float???Sathak
0
is RETURN O IS NEEDED?
0
No not needed
0
😨
0
it's float cuz if one enters a decimal number float data type is required . int data type will not accept decimal
0
Every signed datatype uses the most significant bit (msb) as it's sign, and because using < or > is expensive when dealing with non integer values you could use bitwise-AND with the corresponding value.
bool isNegative(double v) {
unsigned long long* _v = (typeof(_v))&v;
bool isNeg = *_v & ((typeof(*_v))1 << (8*sizeof(*_v) - 1));
delete _v;
return isNeg;
}
0
ya needed it's called success full termination
0
you can also use if(a>=0) as sometimes 0 is considered to be +ve