Introduction
Hi guys, today I will post how to write a basic star
programming in C#, this is generally helpful to the fresher and whoever
preparing for interviews.
Previously I had posted Star Programming 1
static void Main(string[] args)
{
Console.WriteLine("Please
Enter a number");
int num =
Convert.ToInt32(Console.ReadLine());
for (int i = 0; i < num; i++)
{
for (int k = 0; k < num - i-1;
k++)
{
Console.Write(" ");
}
for (int j = 0; j <2 * i + 1;
j++)
{
Console.Write("*");
}
Console.WriteLine();
}
}
|
No comments:
Post a Comment