Print Out a Triangle
Learn about variables and loops, and use them to create the shape of a triangle.
We'll cover the following...
Printing out characters in shapes is often used as beginner programming exercise, because they are easy to understand and visually interesting programs.
Problem
Write a program to print out hashes in a triangle shape, as shown below:
####################################
Drawn shape of a triangle
Purpose
Develop the ability to analyze patterns
Learn about variables
Learn about looping
Analyze
Row | Number of hashes |
1 | 1 |
2 | 2 |
3 | 3 |
... | ... |
n | n |
Hints
Print out text
We can display text using the
puts
...