# Example 1

Create a loop to print following triangle made up of asterisks *.

*
**
***
****
*****
******
*******
********
*********
**********
1
2
3
4
5
6
7
8
9
10

Notice that

  1. This triangle has 10 rows
  2. Every row has one more * than the previous one.

# Solution







 

 








using System;

class MainClass
{
  public static void Main (string[] args)
  {
    for (int i = 0; i < 10; i++)
    {
      for (int j = 0; j <= i; j++)
      {
        Console.Write ("*");
      }
      Console.WriteLine ("");
    }
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

TIP

You can run the code here.

Last Updated: Apr 22, 2020, 1:39 PM