Algo 04B
- Assuming that x is 1, show the result of the following Boolean expressions.
• (true) && (3 > 4)
• !(x > 0) && (x > 0)
• (x != 1) == !(x == 1)
• (x >= 0) || (x < 0)
- List the precedence order of the Boolean operators. Evaluate the following expressions:
• 2 * 2 – 3 > 2 && 4 – 2 > 5
• 2 * 2 – 3 > 2 || 4 – 2 > 5
- Is (x > 0 && x < 10) the same as ((x > 0) && (x < 10))? Is (x > 0 || x < 10 && y < 0) the same as (x > 0 || (x < 10 && y < 0))?
JAWAB :
- Bahwa x adalah 1, menunjukkan hasil dari ekspresi Boolean berikut :
· (true) && (3 > 4)
False, karena 3 tidak lebih dari 4
· !(x > 0) && (x > 0)
False,karena yang pertama benar dan yang kedua salah seperti yang bapak bilang .
· (x != 1) == !(x == 1)
True,karena benar kedua-duanya
· (x >= 0) || (x < 0)
True, karena kedua-duanya benar
- • 2 * 2 – 3 > 2 && 4 – 2 > 5
True kedua-duanya benar
• 2 * 2 – 3 > 2 || 4 – 2 > 5
True kedua-duanya benar
-
Apakah (x mengatakan 0 && x < 10) sama seperti ((x > 0) && (x < 10))? adalah (x mengatakan 0 || x < 10 && y < 0) sama seperti (x mengatakan 0 || (x < 10 && y < 0))?, jawab : Menurut saya kedua-duanya benar, statement ini menghasilkan hasil yang sama .
Binus University
www.binus.ac.id