KnowledgeBoat Logo

Output Questions for Class 10 ICSE Computer Applications

Give the output of the following Java program snippet based on nested loops:

int i,j;
for (i=0; i<4; i++)
{
for (j=i; j>=0; j--) 
System.out.print(j); 
System.out.println();
}

Java

Java Nested for Loops

97 Likes

Answer

0
10
210
3210

Working

For each iteration of outer for loop, inner for loop will iterate from i to 0 printing the above pattern.

Answered By

46 Likes