How to print color stars in c# by user Input

Shubham
Posted by Shubham under C# category on | Points: 40 | Views : 4075
using System;


class triangle_class
{
static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.Red;
int number = Convert.ToInt16(Console.ReadLine());

for (int i = 1; i <= number; i++)
{
for (int j = 1; j <= number - i; j++)
Console.Write(" ");
for (int k = 1; k <= i; k++)
Console.Write(" *");
Console.WriteLine("");
}
Console.ReadLine();
}
}

Comments or Responses

Login to post response