unit 3: Boolean Expressions

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Boolean

True or False

if (x % 2 != 0)

x is odd

if (y != 0)

y is not zero

!=

does not equal

==

The equality operator (sometimes read: "equal equal") is used to compare two values, and returns a Boolean (true/false). Avoid confusion with the assignment operator "=",

&&

and (both)

>

greater than

>=

greater than or equal to

relational operators

have lower precedence than math && is evaluated before ||

y is a greater magnitude than x

if (Math.abs(y) > Math.abs(x))

if-then

if (condition) statement;

x is divisible by 17

if (x % 17 == 0)

x is even

if (x % 2 == 0)

x is bigger than 10 and less then 90

if (x > 10 && x < 90)

y is not a multiple (# that can be divided by another number w/o a remainder) of x

if (y % x != 0)

y is negative

if (y < 0)

y is a non-negative one-digit number

if (y >= 0 && y<=9)

short circuit && (and)

if condition is FALSE then condition is false anyways

short circuit || (or)

if conditional is TRUE then condition is true anyways

Short Circuited Operators

if the left operand is sufficient to determine the result, the right operand is not evaluated

z is less than x or z is greater than y

if(z < x || z > y)

<

less than

<=

less than or equal to

!

not (neither)

||

or (1 or the other)


संबंधित स्टडी सेट्स

Chapter 9: Biotechnology and DNA Technology

View Set

Preguntas prácticas Fundamentos de Ciencia política

View Set

Chapter 25: Assessment of Cardiovascular Function

View Set