Last active
July 14, 2022 05:59
-
-
Save bharathmuddada/9af5826da8cd6b3e21a94c6f4d19877e to your computer and use it in GitHub Desktop.
Print a star pyramid
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 StarPyramid | |
{ | |
public static void Main(String[] args) | |
{ | |
Console.WriteLine("Triangle : "); | |
int n = 5; | |
for (int i = 1; i <= 5; i++) | |
{ | |
for (int j = 1; j <= (n - i); j++) | |
{ | |
Console.Write(" "); | |
} | |
for (int k = 1; k < i * 2; k++) | |
{ | |
Console.Write("*"); | |
} | |
Console.WriteLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment