In the program the following star pattern will be printed.
The program is shown below :
package com.skilledmonster.examples.loops; public class BinaryPyramidNestedForLoopExample_8 { public static void main(String[] args) { for (int i = 1; i <= 6; i++) { for (int j = 1; j <= i; j++) { System.out.print(((i + j) % 2) + " "); } System.out.println(""); } } } |
Output :
No comments:
Post a Comment