0
How did the output of this program become 1????
#include<iostrem.h> Using namespace std; Int main() { Cout<<(0==0) }
10 Réponses
+ 2
0 is equal to 0, right
so the expression 0==0 is true and returns "1", which is displayed by cout
if it was 0==1, answer would be "0", cause 0 is not equal to 1
+ 2
the condition within the brackets is checked, which is true
in c++, "1" represents true and "0" represents false
so your program returns 1
+ 2
the condition is boolean, true meens 1 and false 0(does 0 equals 0)
+ 2
Trying to printing booleans and conditions will print 1 if the bool or condition is true otherwise 0
+ 1
Thanks for clarify my doubts sreejith
+ 1
see 0==0 evaluating to 1 because this expression is true the (==) matches the l-value to r-value and there l-value and r-value are equal
+ 1
Thank you aveek
0
How was it true???
Plz explain breafly...
0
it is a logical expression which evaluates to true or false . When we say say the logical expression is true , the expression returns 1 and When we say say the logical expression is false , the expression returns 0
0
if you want your result to be false
then -
#include <iostream>
using namespace std;
int main() {
int x=0;
if(x)
{
cout << 1;
}
else
{
cout << 0;
}
return 0;
}