+ 1

If x==7: break

Why we are write equal sign twice why it's not enough to write once time

18th Aug 2023, 8:32 PM
Laxmi
Laxmi - avatar
8 ответов
+ 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?
18th Aug 2023, 9:25 PM
Brian
Brian - avatar
+ 3
One equal sign reserved to assign a value to a variable. two equal sign is a compression operator to evaluate two value equality.
18th Aug 2023, 8:40 PM
Yasin Rahnaward
Yasin Rahnaward - avatar
+ 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
19th Aug 2023, 12:27 AM
Dragon RB
Dragon RB - avatar
+ 1
X===7 If x="7" here it is false If x=7 here is true
20th Aug 2023, 4:18 PM
Ganesh Yandigeri
Ganesh Yandigeri - avatar
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
20th Aug 2023, 9:06 AM
Chinmayee N
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)
20th Aug 2023, 10:04 AM
Alhaaz
Alhaaz - avatar