✏️ Explanatory Question

Analyze the given program segment and answer the following questions:


for(int i=3;i<=4;i++ ) {
for(int j=2;j<i;j++ ) {
System.out.print("" ); }
System.out.println("WIN" ); }
  1. How many times does the inner loop execute?
  2. Write the output of the program segment.

👁 105 Views
📘 Detailed Answer
🟢 Easy
💡

Answer with Explanation

  1. Inner loop executes 3 times.
    (For 1st iteration of outer loop, inner loop executes once. For 2nd iteration of outer loop, inner loop executes two times.)

  2. Output:
    WIN
    WIN