# Example 1
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 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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
TIP
You can run the code here.
← Exercise 6 Example 2 →