006-002-012
Nested For: Right Triangle
Medium
Problem Description
Nested For: Right Triangle
In this problem, you will create a program that reads the number of rows n from standard input, then uses nested for loops to draw a right triangle with asterisks (*), controlling the inner loop count with the outer loop variable.
Learning Objective: Understand how to control inner loop count using the outer loop variable
Overview
Read the number of rows from standard input and create a program that draws a right triangle using asterisks (*).
Specifications
- Read integer n (number of rows) from standard input
- Draw an n-row triangle
- Row 1 has 1 asterisk, row 2 has 2, etc.
- Use outer loop variable in inner loop condition
Input Format
n
n: Number of rows (integer)
Output Format (when n=5)
*
**
***
****
*****
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up