MCQ Single Best Answer Moderate

QSelect the infinite loop:

ID: #24155 ICSE Computer Application - Class X - 2025 PYQ 124 views
Question Info
#24155Q ID
ModerateDifficulty
ICSE Computer Application - Class X - 2025 PYQTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A for(int i=1; i<=10; i++)
  • B for(int i=2; i!=0; i-=3)
  • C for(int i=5; j<=5; j++)
  • D for(int i=1; i>=1; i--)
Correct Answer: Option B

Explanation

Correct Infinite Loop

Let's check the correct infinite loop:


for(int i=2; i!=0; i-=3)

Loop Breakdown:

  • Step 1: i = 2 (Condition i != 0 is true → executes)

  • Step 2: i -= 3 (Now i = -1)

  • Step 3: i != 0? Still true → executes again

  • Step 4: i -= 3 (Now i = -4)

  • Step 5: i != 0? Still true → executes again...

  • This never stops because i will always be != 0.

Correct Answer: (b) for(int i=2; i!=0; i-=3) (Infinite Loop)

Share This Question

Challenge a friend or share with your study group.