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");
}
Console.ReadKey();
}
}
class pat6
{
public static void Main(string[] args)
{
abc a = new abc();
a.fun();
}
}
Output will be:
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");
}
Console.ReadKey();
}
}
class pat6
{
public static void Main(string[] args)
{
abc a = new abc();
a.fun();
}
}
Output will be:
No comments :
Post a Comment