KnowledgeBoat Logo

Output Questions for Class 10 ICSE Computer Applications

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

int y,p;
for (int x=1; x<=3; x++)
{
for (y=1; y<=2; y++)
{
p = x * y;
System.out.print(p);
}
System.out.println( );
}

Java

Java Nested for Loops

114 Likes

Answer

12
24
36

Working

xypRemarks
1111st iteration of outer for loop
 22
2122nd iteration of outer for loop
 24
3133rd iteration of outer for loop
 26

Answered By

56 Likes