# Exercise 4

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

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

# Hint

To solve this problem, you will need two loops nested inside a loop.

 

 




 







for (int i = 0; i < 10; // write the code)
{
  for (int j // write the code)
  {
    // write the code
  }

  for (int j // write the code)
  {
    // write the code
  }

  Console.WriteLine("");
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14

Notice that inside the loop i, we have two loops, first at line 3 and second at line 8. Both inner loops have variable j. It would work because both variables are in different scope.

# Instruction

Notice there is a space preceding the first asterisk in the last row. I have replaced space with to highlight the leading space.

␣*␣*␣*␣*␣*␣*␣*␣*␣*␣*
1

Your submission must also print the leading space in the last row.

Last Updated: May 4, 2020, 4:49 PM