nested for loop statement in C#

 

For Example: Write a program to demonstrate the use of nested for loop statement.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

 

namespace ConsoleApplication4

{

classProgram

    {

staticvoid Main(string[] args)

        {

int i, j;

for (i = 1; i <= 5; i++)

            {

for (j = 1; j <= i; j++) //Nested for loop

                {

Console.Write(j);

                }

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#