+ 1
If x==7: break
Why we are write equal sign twice why it's not enough to write once time
8 Respostas
+ 7
Laxmi there is a need to make sure the syntax can leave no doubt about the programmer's intent. Consider the problems interpreting the code if == were not used. In the following expression, how would you interpret what the code should do?
a = b = c
The interpreter cannot determine which of the equals signs should be used for comparison (if any), and which should be used for assignment (if any).
They could be two value assignments, or they could be one boolean assignment.
a = b == c
Do you see the need to distinguish between assignment operator and comparison operator?
+ 3
One equal sign reserved to assign a value to a variable.
two equal sign is a compression operator to evaluate two value equality.
+ 1
Mirielle === is for checking if the 2 operands are equal and identical(means of the same type, refer to the same object).
console.log("12"==12); //true
console.log("12"===12); //false
+ 1
X===7
If x="7" here it is false
If x=7 here is true
0
In Java, x=7 means that the value or the number 7 is assigned to the variable x which means that now the variable x will contain the value 7 whereas x==7 is a Boolean operator which checks whether the value of the variable x is 7 or not... I hope this cleared your doubt :D
0
'==' is a comparison sign
like (x==7) ← here we are comparing x with 7 , if x=7 , statement is true else false.
eg.
int x=7;
bool y=(x==7);
cout<<y;
output -
1 ← (1 means true)