To print the Half Pyramid pattern program using stars in C#
Solution:
Output
Solution:
using System;
namespace Reference
{
public class Pattern
{
public void PrintPattern(int no)
{
for(int i=0;i<no;i++)
{
for(int j=0;j<=i;j++)
{
Console.Write("*");
}
Console.WriteLine();
}
}
}
public class Test
{
public static void Main()
{
Console.WriteLine("Please Enter n:");
var n=Console.ReadLine();
int number =Convert.ToInt32(n);
Pattern po = new Pattern();
po.PrintPattern(number);
}
}
}
Output
Please Enter n: * ** *** **** *****
Comments
Post a Comment