in Java please write code ,as simple and clean as possible.Thank u
Write nested for loops to produce the following output:
....1 ...22 ..333 .4444 55555
Dear student,
please find the below code for producing the required output. For understanding refer to the comments
Code:
public class Main
{
public static void main(String[] args)
{
for(int i=1;i<=5;i++) // used for looping 5
times
{
for(int j=1;j<=5-i;j++) //used for printing
"."
{
System.out.print("."); // prints "."
}
for(int j=1;j<=i;j++) // used for printing row
number
{
System.out.print(i); // prints row number
}
System.out.println(); // prints new
line
}
}
}
Output:
If you have any doubt please comment below and please don't forget to hit the like button.
Thank you :)
Get Answers For Free
Most questions answered within 1 hours.