Write the code for the following output:
1
2 3
4 5 6
7 8 9 10
As you can see, the output used in this example is the reverse of the output from first example:
int k=1;
for(int i=1;i<5;i++)
// (outer for loop) it will loop for 4 times
{
//System.out.println("outer loop started");
for(int j=1;j<=i;j++) //(inner for loop)
{
System.out.print("k");
System.out.print(" ");
k++;
}
System.out.println(" ");
}