Consider the following program segment in C programming language: i = 6720; j…

2018

Consider the following program segment in C programming language: i = 6720; j = 4; while ((i % j) == 0) { i = i / j; j = j + 1; } On termination, j will have the value:

Answer: C. 9Start: i = 6720, j = 4 6720 % 4 = 0 → i = 1680, j = 5 1680 % 5 = 0 → i = 336, j = 6 336 % 6 = 0 → i = 56, j = 7 56 % 7 = 0 → i = 8, j = 8 8 % 8 = 0 → i = 1, j…

  1. A.

    4

  2. B.

    8

  3. C.

    9

  4. D.

    6720

Attempted by 770 students.

Show answer & explanation

Correct answer: C

Start: i = 6720, j = 4

6720 % 4 = 0 → i = 1680, j = 5

1680 % 5 = 0 → i = 336, j = 6

336 % 6 = 0 → i = 56, j = 7

56 % 7 = 0 → i = 8, j = 8

8 % 8 = 0 → i = 1, j = 9

1 % 9 ≠ 0 → loop stops

👉 Final value of j = 9

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

Explore the full course: Up Lt Grade Assistant Teacher 2025

Loading lesson…