+ 1
can anyone explain me clearly what the logical operators (and,or,not) are plz? im stuck...
14 odpowiedzi
+ 6
https://code.sololearn.com/Wj6VyBq8POTl/?ref=app
Please check that code and try to follow each condition
+ 5
AND is to check TRUE two conditions
Example: if (a>10 and a<15)
if both conditions are TRUE then result is TRUE and in that example 'a' is a number between 11 and 14 but if some or both are FALSE then result is FALSE
+ 5
NOT is to check "negative" condition.
Example: If (not (a>10))
If a=5 then not(5>10)=not(false)=TRUE
If a=11 then not(11>10)=not(true)=FALSE
+ 4
OR is to check TRUE one or both conditions.
Example: if (a>10 or a<15)
if both conditions are TRUE then result is TRUE, if a>10 and not a<15 then result is TRUE and 'a' could be a number from 15 to infinite, if not a>10 and yes a<15 then result is TRUE and 'a' could be a number from 10 to minus infinite. Of course if both conditions are FALSE then result is FALSE
+ 2
Can you explain in a more simple way... I dont get it and its bothering me really bad
+ 2
I wanna code it tho how do i put it? I tried the same way as the AND operator an doesnt work
+ 2
Ok thanks a lot
+ 1
Ok and what about the "NOT" one? It says "if the operand is false,and false,if the operand is true" what does that mean?
+ 1
example for NOT:
x= 3,
y=5;
if( x!== y) // 3 not 5 = true
{
/* do something*/
}
(x !== y) is same as (3 NOT 5) and its True
because 3 not equal 5
+ 1
Oh i see...
+ 1
in js use :
"&&" as "AND" operator,
"||" as "OR" operator,
"!" as "NOT" operator
+ 1
in the future, if u have some problems - show us your code to understand where's your mistake
+ 1
Ok thank u so much guys
+ 1
Oh i see why now... I didnt do the if and else yet