Output tabular data with for loop - CSharp Language Basics

CSharp examples for Language Basics:for

Description

Output tabular data with for loop

Demo Code

using System;/* w  w  w  .  j a  v a2  s .  c om*/
class AreaCalculator
{
   public static void Main()
   {
      int i;
      int width;
      int height;
      height = 1000;
      width = 100;
      Console.WriteLine("height   width     area\n");
      for (i=0; i <= 10; i++)
      {
         Console.WriteLine("{0}     {1}      {2}",
         height, width, height * width);
         height = height + 100;
         width = width + 10;
      }
   }
}

Result


Related Tutorials