How to print right triangle in c#.?
using System;
class Program
{
static void Main(string[] args)
{
int n = 10;
int i, j, k;
for (i = 1; i <= n; i++)
{
for (j = 1; j <= n - i; j++)
{
Console.Write(" ");
}
for (k = 1; k <= i; k++)
{
Console.Write("*");
}
Console.WriteLine("");
}
Console.ReadLine();
}
}
Output is:
No comments :
Post a Comment