Use two variables to control for loop - CSharp Language Basics

CSharp examples for Language Basics:for

Description

Use two variables to control for loop

Demo Code

using System;//from   w  w w . jav a  2 s .co m
class OneThird
{
   public static void Main()
   {
      int i;
      int j;
      Console.WriteLine("Value of\n i   j\n");
      for (i=0, j=21; i <= j; i++, j=j-2)
         Console.WriteLine(" {0}   {1}", i, j);
      }
}

Result


Related Tutorials