Write nested for loops to produce the following output:
....1 ...2. ..3.. .4... 5....
//TestCode.java public class TestCode { public static void main(String[] args) { int i,j,n=5; for(i = 1;i<=n;i++) { for (j = 1; j <= n; j++) { if (i + j == n + 1) { System.out.print(i); } else { System.out.print("."); } } System.out.println(); } } }
Get Answers For Free
Most questions answered within 1 hours.