Venciity

[Jumpstart C#] loops demo - Triangle

Jan 24th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.38 KB | None | 0 0
  1. using System;
  2.  
  3. class Triangle
  4. {
  5.     static void Main()
  6.     {
  7.         Console.Write("n = ");
  8.         int n = Int32.Parse(Console.ReadLine());
  9.         Console.WriteLine();
  10.  
  11.         for (int row = 1; row <= n; row++)
  12.         {
  13.             for (int col = 1; col <= row; col++)
  14.             {
  15.                 Console.Write("{0} ", col);
  16.             }
  17.             Console.WriteLine();
  18.         }
  19.  
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment