# Example 2
Create a loop to print following triangle made up of asterisks *.
**********
*********
********
*******
******
*****
****
***
**
*
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
Notice that
- This triangle has 10 rows
- Every row has one less
*than the previous one.
# Solution
using System;
class MainClass
{
public static void Main (string[] args)
{
for (int i = 10; i > 0; 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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
TIP
You can run the code here.
← Example 1 Exercise 1 →