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

Popular posts from this blog

simple program C#

Regular Expression Validator Control in asp.net

two dimension array in C#