Given i = 0, j = 1, k = –1 x = 0.5, y = 0.0 What is the output of the…

2016

Given i = 0, j = 1, k = –1

x = 0.5, y = 0.0

What is the output of the following expression in C language ?

x * y < i + j || k

  1. A.

    - 1

  2. B.

    0

  3. C.

    1

  4. D.

    2

Attempted by 641 students.

Show answer & explanation

Correct answer: C

Answer: 1

Reasoning:

  • Compute x * y: 0.5 * 0.0 = 0.0.

  • Compute i + j: 0 + 1 = 1.

  • Compare: 0.0 < 1 is true. In C a relational operator produces an int value 1 for true (and 0 for false).

  • Apply logical OR: the left operand is true (1), so || returns 1 and short-circuits (the value of k is not used).

  • Final result in C is the integer 1.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor