Understanding OR Logic
+18
kylenicole
Alliah Faith
Asdfghjkl
jaketadios04
Emie Ligutan
rapzie badoodles
Ferre
iramae
ilovebts
Myra Monique Acuna
airojames
Pox
Lawrence
althea faye
Sean Monacillo
Luwiezz
justjoking10
rheigne
22 posters
Page 1 of 4 • 1, 2, 3, 4
Understanding OR Logic
Wed Jul 25, 2018 9:05 am
Using the OR Operator
If you need to take action when either one or the other of two conditions is met, you can use two separate, nested selection structures, as in the previous examples. However, most programming languages allow you to make two or more decisions in a single comparison by using a conditional OR operator (or simply the OR operator).
When you use the logical OR operator, only one of the listed conditions must be met for the resulting action to take place. Quick reference 2-1 contains the truth table for the OR operator. As you can see in the table, the entire expression x OR y is false only when x and y each are false individually.
Quick reference 2-1 OR Logic Truth Table
For example, suppose the cell phone company has established a new fee schedule as follows: The basic monthly service bill is $30. An additional $20 is billed to customers who make more than 100 calls or send more than 200 text messages.
If the programming language you use supports the OR operator, you still must realize that the comparison you place first is the expression that will be evaluated first, and cases that pass the test of the first comparison will not proceed to the second comparison. As with the AND operator, this feature is called short-circuiting. The computer can ask only one question at a time; even when you write code as shown at the top of Figure 2-1, the computer will execute the logic shown at the bottom.
[/color]
Figure 2-1 Using an OR operator and the logic behind it
Logic Example
Let's say people GOING IN is x(considered 1 when a man is sensed and 0 if none), those who are GOING OUT is y(considered 1 when a man is sensed and 0 if none), and the movement of the door is the result(considered 1 when it opens and 0 if not).
With that, I have made this truth table.
If you need to take action when either one or the other of two conditions is met, you can use two separate, nested selection structures, as in the previous examples. However, most programming languages allow you to make two or more decisions in a single comparison by using a conditional OR operator (or simply the OR operator).
When you use the logical OR operator, only one of the listed conditions must be met for the resulting action to take place. Quick reference 2-1 contains the truth table for the OR operator. As you can see in the table, the entire expression x OR y is false only when x and y each are false individually.
Quick reference 2-1 OR Logic Truth Table
For example, suppose the cell phone company has established a new fee schedule as follows: The basic monthly service bill is $30. An additional $20 is billed to customers who make more than 100 calls or send more than 200 text messages.
If the programming language you use supports the OR operator, you still must realize that the comparison you place first is the expression that will be evaluated first, and cases that pass the test of the first comparison will not proceed to the second comparison. As with the AND operator, this feature is called short-circuiting. The computer can ask only one question at a time; even when you write code as shown at the top of Figure 2-1, the computer will execute the logic shown at the bottom.
[/color]
Figure 2-1 Using an OR operator and the logic behind it
Logic Example
Figure 2-2 An automatic Glass Door
Let's say people GOING IN is x(considered 1 when a man is sensed and 0 if none), those who are GOING OUT is y(considered 1 when a man is sensed and 0 if none), and the movement of the door is the result(considered 1 when it opens and 0 if not).
With that, I have made this truth table.
Did you UNDERSTAND OR LOGIC?
If yes, would you please give different example/application of it?
else comment down below your reactions/questions.
If yes, would you please give different example/application of it?
else comment down below your reactions/questions.
- rheigne
- Posts : 1
Join date : 2018-08-01
?
Wed Aug 01, 2018 6:18 pm
The topic is very well explained but sir, naguguluhan lang ako, anong pinagkaiba niya sa While Statement? Yun po kasi ang hindi ko mapagtanto
Re: Understanding OR Logic
Wed Aug 01, 2018 6:28 pm
rheigne wrote:The topic is very well explained but sir, naguguluhan lang ako, anong pinagkaiba niya sa While Statement? Yun po kasi ang hindi ko mapagtanto
yung while eh ginagamit sa looping, hindi pa naman tayo nagloloop dito
- justjoking10Guru
- Posts : 19
Join date : 2018-08-01
Re: Understanding OR Logic
Wed Aug 01, 2018 6:36 pm
rheigne wrote:The topic is very well explained but sir, naguguluhan lang ako, anong pinagkaiba niya sa While Statement? Yun po kasi ang hindi ko mapagtanto
Ang topic ni sir dito ay about selection. S looping p ung while statement.
- janderGuest
Re: Understanding OR Logic
Wed Aug 01, 2018 6:52 pm
This topic is very nice, sir you're a great teacher,but I do not understand much, I'm a little confused, but I try my best to understand.
- justjoking10Guru
- Posts : 19
Join date : 2018-08-01
Re: Understanding OR Logic
Wed Aug 01, 2018 6:58 pm
The topic is very well explained sir.
Re: Understanding OR Logic
Wed Aug 01, 2018 7:07 pm
That's good to know from you. Are you sure you understand? Can you give another example?justjoking10 wrote:The topic is very well explained sir.
Re: Understanding OR Logic
Thu Aug 02, 2018 7:42 am
I will also give my best for you to understand. What part are you confused?jander wrote:This topic is very nice, sir you're a great teacher,but I do not understand much, I'm a little confused, but I try my best to understand.
- LuwiezzNewbie
- Posts : 3
Join date : 2018-08-02
I LOVE IT
Thu Aug 02, 2018 6:48 pm
Thank you for posting this, a big help for me understanding OR logic. I will assure you that I will perform well the next time
Re: Understanding OR Logic
Thu Aug 02, 2018 7:37 pm
Good to know that this forum helps you. You can share this to your friends to let them know and understand OR Logic too.Luwiezz wrote:Thank you for posting this, a big help for me understanding OR logic. I will assure you that I will perform well the next time
- Sean MonacilloGuru
- Posts : 19
Join date : 2018-08-02
Re: Understanding OR Logic
Thu Aug 02, 2018 8:18 pm
Regarding sa tanong ni rheign . Yung WHILE STATEMENT sa loop yun rheign tapos kapag OR LOGIC ang gamit mo lang jan is yung IF STATEMENT . pero pwede ka din naman ata mag OR LOGIC SA WHILE LOOP I guess. di lang ako sure sana masagot ni sir if pwede . hehehe .
Sent from Topic'it App
Sent from Topic'it App
- justjoking10Guru
- Posts : 19
Join date : 2018-08-01
Re: Understanding OR Logic
Thu Aug 02, 2018 8:45 pm
Admin wrote:That's good to know from you. Are you sure you understand? Can you give another example?justjoking10 wrote:The topic is very well explained sir.
Pamasahe po s jeep.
if customer is Senior OR Student then
WITH DISCOUNT
else
NO DISCOUNT
Re: Understanding OR Logic
Thu Aug 02, 2018 8:53 pm
Yes you can incorporate OR in a Loop.Sean Monacillo wrote:Regarding sa tanong ni rheign . Yung WHILE STATEMENT sa loop yun rheign tapos kapag OR LOGIC ang gamit mo lang jan is yung IF STATEMENT . pero pwede ka din naman ata mag OR LOGIC SA WHILE LOOP I guess. di lang ako sure sana masagot ni sir if pwede . hehehe .
Sent from Topic'it App
Re: Understanding OR Logic
Thu Aug 02, 2018 8:54 pm
Very Good. Ang nagkakagulo ngayon dyan eh yung process after that, diba 20% ang discount so magkano dapat ang binabayad ng STUDENT or SENIOR?justjoking10 wrote:Admin wrote:That's good to know from you. Are you sure you understand? Can you give another example?justjoking10 wrote:The topic is very well explained sir.
Pamasahe po s jeep.
if customer is Senior OR Student then
WITH DISCOUNT
else
NO DISCOUNT
- justjoking10Guru
- Posts : 19
Join date : 2018-08-01
Re: Understanding OR Logic
Thu Aug 02, 2018 8:57 pm
Admin wrote:Very Good. Ang nagkakagulo ngayon dyan eh yung process after that, diba 20% ang discount so magkano dapat ang binabayad ng STUDENT or SENIO??justjoking10 wrote:Admin wrote:That's good to know from you. Are you sure you understand? Can you give another example?justjoking10 wrote:The topic is very well explained sir.
Pamasahe po s jeep.
if customer is Senior OR Student then
WITH DISCOUNT
else
NO DISCOUNT
9 pesos is the minimum fare.
9 * 0.20 = 1.80.
9 - 1.80 = 7.20
Round to 7
Pero sir mas maikli po sya pag ganto.
9 * 0.80 = 7.20
Round to 7
- Sean MonacilloGuru
- Posts : 19
Join date : 2018-08-02
Re: Understanding OR Logic
Thu Aug 02, 2018 8:58 pm
Thank you sir tama na yung nasa isip ko heheheAdmin wrote:Yes you can incorporate OR in a Loop.Sean Monacillo wrote:Regarding sa tanong ni rheign . Yung WHILE STATEMENT sa loop yun rheign tapos kapag OR LOGIC ang gamit mo lang jan is yung IF STATEMENT . pero pwede ka din naman ata mag OR LOGIC SA WHILE LOOP I guess. di lang ako sure sana masagot ni sir if pwede . hehehe .
Sent from Topic'it App
Re: Understanding OR Logic
Thu Aug 02, 2018 8:58 pm
Yun nga ehh kaso "may mga ilan", na driver na 8 ang singil.justjoking10 wrote:Admin wrote:Very Good. Ang nagkakagulo ngayon dyan eh yung process after that, diba 20% ang discount so magkano dapat ang binabayad ng STUDENT or SENIO??justjoking10 wrote:Admin wrote:That's good to know from you. Are you sure you understand? Can you give another example?justjoking10 wrote:The topic is very well explained sir.
Pamasahe po s jeep.
if customer is Senior OR Student then
WITH DISCOUNT
else
NO DISCOUNT
9 pesos is the minimum fare.
9 * 0.20 = 1.80.
9 - 1.80 = 7.20
Round to 7
Pero sir mas maikli po sya pag ganto.
9 * 0.80 = 7.20
Round to 7
- althea fayeGuru
- Posts : 10
Join date : 2018-08-07
Re: Understanding OR Logic
Tue Aug 07, 2018 8:45 am
What is the purpose of logic gates?
- althea fayeGuru
- Posts : 10
Join date : 2018-08-07
Re: Understanding OR Logic
Tue Aug 07, 2018 8:46 am
What is the purpose of logic gates?
Re: Understanding OR Logic
Tue Aug 07, 2018 9:05 am
It used to create a wider and specific logic. Logic gates can be found in an IC, and a group of IC is a huge contribution to build a computer.althea faye wrote:What is the purpose of logic gates?
- althea fayeGuru
- Posts : 10
Join date : 2018-08-07
Re: Understanding OR Logic
Tue Aug 07, 2018 9:39 am
it can help a lot for us inspiring programmers .Luwiezz wrote:Thank you for posting this, a big help for me understanding OR logic. I will assure you that I will perform well the next time
- iramaeGuru
- Posts : 10
Join date : 2018-08-08
Re: Understanding OR Logic
Wed Aug 08, 2018 7:59 am
Ang Boolean expressions ang hindi talaga nawawala pagdating sa programming. Parang yun na din kase yung basis kung pano tatakbo yung program.
Re: Understanding OR Logic
Wed Aug 08, 2018 8:27 am
Yes, in computing its a matter of True or False, On or Off, 1 or 0.iramae wrote:Ang Boolean expressions ang hindi talaga nawawala pagdating sa programming. Parang yun na din kase yung basis kung pano tatakbo yung program.
- LawrenceGuru
- Posts : 10
Join date : 2018-08-11
Re: Understanding OR Logic
Sat Aug 11, 2018 6:29 pm
i think yung while is for looping lang siyarheigne wrote:The topic is very well explained but sir, naguguluhan lang ako, anong pinagkaiba niya sa While Statement? Yun po kasi ang hindi ko mapagtanto
- LawrenceGuru
- Posts : 10
Join date : 2018-08-11
Re: Understanding OR Logic
Sat Aug 11, 2018 6:34 pm
sir pwede po siguro example po yung sa pag gigitara sir. if gusto po natin matuto mag gitara. dalawang choices po bale its either na hihiram tayo ng gitara OR bibili po ng gitara. it means po kahit san po sa dalawa, matuto ka padin po mga gitaraAdmin wrote:That's good to know from you. Are you sure you understand? Can you give another example?justjoking10 wrote:The topic is very well explained sir.
Page 1 of 4 • 1, 2, 3, 4
Permissions in this forum:
You cannot reply to topics in this forum
|
|