Solve this! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Solve this!

What's your answer , https://www.sololearn.com/post/114598/?ref=app

23rd Jun 2019, 5:14 AM
Neha
Neha - avatar
4 Answers
+ 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'.
24th Jun 2019, 3:11 AM
Manoj
Manoj - avatar
+ 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
23rd Jun 2019, 7:13 AM
๐Ÿ‡ฎ๐Ÿ‡ณOmkar๐Ÿ•‰
๐Ÿ‡ฎ๐Ÿ‡ณOmkar๐Ÿ•‰ - avatar
+ 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 ๐Ÿ˜„
23rd Jun 2019, 7:17 AM
๐Ÿ‡ฎ๐Ÿ‡ณOmkar๐Ÿ•‰
๐Ÿ‡ฎ๐Ÿ‡ณOmkar๐Ÿ•‰ - avatar
+ 4
Damn hierarchy... Got it:) Thanks Anna , ~ swim ~
23rd Jun 2019, 5:27 AM
Neha
Neha - avatar