Created
November 23, 2022 12:53
-
-
Save rohityadavcloud/1a332e9be8d45d43f158674c288bfb5f to your computer and use it in GitHub Desktop.
ChristmasTree
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ChristmasTree { | |
public static void main(String[] args) { | |
for (int i = 0; i < 10; i++) { | |
for (int j = 0; j < 10 - i; j++) { | |
System.out.print(" "); | |
} | |
for (int k = 0; k < (2 * i + 1); k++) { | |
System.out.print("*"); | |
} | |
System.out.println(); | |
} | |
System.out.println(String.format("%12s", "| |")); | |
} | |
} | |
/* | |
Output: | |
* | |
*** | |
***** | |
******* | |
********* | |
*********** | |
************* | |
*************** | |
***************** | |
******************* | |
| | | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment