You are here: Home > Uncategorized > Algo 04B

Algo 04B

  1. 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)

  1. 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

  1. 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 :

  1. 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 * 2 – 3 > 2 && 4 – 2 > 5

    True kedua-duanya benar

        2 * 2 – 3 > 2 || 4 – 2 > 5

    True kedua-duanya benar

  3. 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

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS

Leave a Reply