pattern in C#
For Example: Write a program to print
following output using for loop.
*
* *
* * *
* * * *
* * * * *
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
Class Program
{
Static void Main(string[] args)
{
int i, j;
for (i = 1; i <= 5; i++)
{
for (j = 1; j <= i; j++) //Nested for
loop
{
Console.Write("*");
}
Console.Write("\n");
}
Console.ReadLine();
}
}
}
Output:
Comments
Post a Comment