using System;
class abc
{
int n, j;
public void fun()
{
Console.WriteLine("Enter the number of rows : ");
n = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Pattern is : ");
for (int i = 1; i <= n; i++)
{
for (j = 1; j <= n - i; j++)
{
Console.Write(" ");
}
for (j = 1; j <= (2 * i) - 1; j++)
{
Console.Write("*");
}
Console.Write("\n");
}
for (int i = n - 1; i > 0; i--)
{
for (j = n - i; j > 0; j--)
{
Console.Write(" ");
}
for (j = (2 * i) - 1; j > 0; j--)
{
Console.Write("*");
}
Console.Write("\n");
}
Console.ReadKey();
}
}
class pat9
{
public static void Main(string[] args)
{
abc a = new abc();
a.fun();
}
}
class abc
{
int n, j;
public void fun()
{
Console.WriteLine("Enter the number of rows : ");
n = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Pattern is : ");
for (int i = 1; i <= n; i++)
{
for (j = 1; j <= n - i; j++)
{
Console.Write(" ");
}
for (j = 1; j <= (2 * i) - 1; j++)
{
Console.Write("*");
}
Console.Write("\n");
}
for (int i = n - 1; i > 0; i--)
{
for (j = n - i; j > 0; j--)
{
Console.Write(" ");
}
for (j = (2 * i) - 1; j > 0; j--)
{
Console.Write("*");
}
Console.Write("\n");
}
Console.ReadKey();
}
}
class pat9
{
public static void Main(string[] args)
{
abc a = new abc();
a.fun();
}
}
Output will be:
impressive blog , keep post and if you are intresting in software developer, java developer then check out java course in satara
ReplyDelete