Pattern printing program program number 54
Pattern printing program Implementation:
using System;
namespace patternProblem
{
class Pattern121
{
public static void Main(string[] args)
{
Console.WriteLine("Enter loop iteration times: ");
int n = Convert.ToInt32(Console.ReadLine());
int j;
int i;
Console.WriteLine("-----Output-----");
Console.WriteLine();
for (i = 1; i <= n; i++)
{
for (j = n; j >= i; j--)
{
Console.Write(" ");
}
for (j = 1; j <= i; j++)
{
Console.Write("*");
}
for (j = j - 1; j >= 1; j--)
{
Console.Write("*");
}
Console.WriteLine();
}
for (i = n; i >= 1; i--)
{
for (j = n; j >= i; j--)
{
Console.Write(" ");
}
for (j = 1; j <= i; j++)
{
Console.Write("*");
}
for (j = j - 1; j >= 1; j--)
{
Console.Write("*");
}
Console.WriteLine();
}
Console.ReadKey();
}
}
}
Comments
Post a Comment