Categories
  Encyclosphere.org ENCYCLOREADER
  supported by EncyclosphereKSF

Conditional Operator

From Wikiversity - Reading time: 2 min


Type classification: this is a lesson resource.

Welcome! This is a lesson in the Introductory Discrete Mathematics for Computer Science course here at Wikiversity.

Previous lesson: Logical XOR

Your Next-to-Last Operator!

[edit | edit source]

The conditional operator looks like this:

It is a dyadic operator.

Perhaps I should explain conditional operators through a story. Let's suppose that Joe Lion is given a wildebeest if he beats Handsome Dan XVII. Thus, becomes "Joe Lion beats Handsome Dan" and becomes "Joe Lion is given a wildebeest." The order of p and q are important, and so p and q are given special terms when the conditional operator is used. p is the antecedent. q is the consequent.

There are four possible outcomes in this story:

1. Joe Lion beats Handsome Dan, and is given a wildebeest. (p is true and q is true)

  • is true.

2. Joe Lion beats Handsome Dan, but is not given a wildebeest. (p is true and q is false)

  • is false. In other words, the condition (that Joe Lion is given a wildebeest if he beats Handsome Dan) is violated.

3. Joe Lion does not beat Handsome Dan, yet is given a wildebeest. (p is false and q is true)

  • is true. The conditional statement (that Joe Lion is given a wildebeest if he beats Handsome Dan) has not been violated, because violation only occurs if the antecedent is true.

4. Joe Lion does not beat Handsome Dan, and is not given a wildebeest. (p is false and q is false)

  • is true. The conditional statement (that Joe Lion is given a wildebeest if he beats Handsome Dan) has not been violated, because violation only occurs if the antecedent is true.

Truth Table for the Conditional.

[edit | edit source]
T T T
T F F
F T T
F F T

Next Lesson

[edit | edit source]

The next lesson is called Biconditional Operator.


Licensed under CC BY-SA 3.0 | Source: https://en.wikiversity.org/wiki/Conditional_Operator
30 views | Status: cached on July 25 2025 18:22:05
↧ Download this article as ZWI file
Encyclosphere.org EncycloReader is supported by the EncyclosphereKSF