+ 3
Solve this!
What's your answer , https://www.sololearn.com/post/114598/?ref=app
6 odpowiedzi
+ 12
!( 1 || 0 && !1 ) this was your expression. Inorder to solve this expression you should have an idea about operator precedence. I think you have evaluated it in this way :
!((1||0)&&!1) but it's wrong you'll yeild '1' in this case. But the correct way of approach is !(1||(0&&!1)) as this will give the answer '0'.
+ 7
In most of the computer languages or say in computer itself 0 stands for false and any nonzero (mostly 1)number stands for true.
Let's move forward ➡
|| is logical OR
If any of its operanad is true then it returns true (1) if all operands are false then it returns false
EX.
true||false. 👈 this returns true
&& is logical AND
if all of it's operand are true then only it returns true(1) or returns false(0).
! Is logical not that makes a true expression false and vice versa.
EX. (1==1) is true but if you apply !
Like.=> !( 1==1) 👈 results false
After knowing these basic concepts it's much simpler to solve this problem.
Start from inner parentheses ()
! Has highest precedence over other operators and || has least precedence.
So executionof inner parentheses be like below
(1||0&&!1)
(1||0&&0)
(1||0)
(1)
So statements inside inner paratheses give us true (1)
But on applying. ! Operator it becomes false (0)
And printf("%d",!(1||0&&!1));
Gives output 0
+ 6
~ swim ~ already answered 😅
I found that post in feed and started typing 😅 swim you made it much simpler man.
Great job.I always watch you helping others 😊
Lots of respect for you dear 😄
+ 4
Damn hierarchy... Got it:)
Thanks Anna , ~ swim ~