- This program is example for to print the right angle triangle in the form of descending and ascending shape.
- Length of triangle depends on what ever the number we entered.
public static void Main(string[] args)
{
Console.Write("Enter a number: ");
int n = Convert.ToInt32(Console.ReadLine());
Console.WriteLine();
for (int i = n; i >= 0; i--)
{
for (int j = 1; j <= i; j++)
Console.Write(j.ToString());
Console.WriteLine();
}
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= i; j++)
Console.Write(j.ToString());
Console.WriteLine();
}
Console.WriteLine();
Console.ReadLine();
}
No comments