using System;
class Program
{
static void Main(string[] args)
{
int i, j, n;
Console.WriteLine("Enter the no for V shape stars");
n = int.Parse(Console.ReadLine());
Console.Write("\n");
for (i = 1; i <= n; i++)
{
for (j = 1; j <= i; j++)
{
Console.Write("*");
}
for (j = n; j >= i; j--)
{
Console.Write(" ");
}
for (j = n - 1; j >= i; j--)
{
Console.Write(" ");
}
for (j = 1; j <= i; j++)
{
Console.Write("*");
}
Console.WriteLine();
}
Console.ReadKey();
}
}
Output:
class Program
{
static void Main(string[] args)
{
int i, j, n;
Console.WriteLine("Enter the no for V shape stars");
n = int.Parse(Console.ReadLine());
Console.Write("\n");
for (i = 1; i <= n; i++)
{
for (j = 1; j <= i; j++)
{
Console.Write("*");
}
for (j = n; j >= i; j--)
{
Console.Write(" ");
}
for (j = n - 1; j >= i; j--)
{
Console.Write(" ");
}
for (j = 1; j <= i; j++)
{
Console.Write("*");
}
Console.WriteLine();
}
Console.ReadKey();
}
}
Output:
No comments :
Post a Comment