006-004-012
Advanced Nested Loop Patterns
Hard
Problem Description
Advanced Nested Loop Patterns
In this problem, you will create a program that reads the number of rows n from standard input, uses nested loops to draw an n-row right triangle pattern with *, and calculates and displays the total count of * to standard output.
Learning Objective: Understand complex loop processing combining nested loops with break/continue
Overview
Learn to generate 2D patterns using nested loops and control loop execution based on conditions.
Input Format
n
n: number of rows in the triangle (positive integer)
Specifications
- Display a right triangle pattern of
nrows using* - For each row i, display
*from 1 to i times - After the triangle, display the total count of
*
Input/Output Example
Input:
5
Output:
*
**
***
****
*****
Total: 15
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