Output:-
*
* *
* * *
* * * *
* * * * *
--- till n length
Code:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Program
{
class Program
{
static void Main(string[] args)
{
int length = Convert.ToInt32(Console.ReadLine());
Console.Write(Environment.NewLine);
for (int i = 0; i < length; i++)
{
string printValues = string.Empty;
for (int j = 1; j <= i + 1; j++)
{
string printStar= "*";
printValues = printValues + " " + printStar;
if (i + 1 == j)
{
Console.WriteLine(printValues);
}
}
}
Console.ReadLine();
}
}
}
*
* *
* * *
* * * *
* * * * *
--- till n length
Code:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Program
{
class Program
{
static void Main(string[] args)
{
int length = Convert.ToInt32(Console.ReadLine());
Console.Write(Environment.NewLine);
for (int i = 0; i < length; i++)
{
string printValues = string.Empty;
for (int j = 1; j <= i + 1; j++)
{
string printStar= "*";
printValues = printValues + " " + printStar;
if (i + 1 == j)
{
Console.WriteLine(printValues);
}
}
}
Console.ReadLine();
}
}
}
No comments:
Post a Comment