Practice Example 2: Printing A Right-angled Triangle Pattern (7.5) - Nested for Loops
Students

Academic Programs

AI-powered learning for grades 8-12, aligned with major curricula

Professional

Professional Courses

Industry-relevant training in Business, Technology, and Design

Games

Interactive Games

Fun games to boost memory, math, typing, and English skills

Example 2: Printing a Right-Angled Triangle Pattern

Practice - Example 2: Printing a Right-Angled Triangle Pattern

Enroll to start learning

You’ve not yet enrolled in this course. Please enroll for free to listen to audio lessons, classroom podcasts and take practice test.

Learning

Practice Questions

Test your understanding with targeted questions

Question 1 Easy

What does a nested loop do in Java?

💡 Hint: Think about how many loops you see.

Question 2 Easy

How many lines will the outer loop iterate if it runs from 1 to 5?

💡 Hint: Count the numbers from 1 to 5.

4 more questions available

Interactive Quizzes

Quick quizzes to reinforce your learning

Question 1

How many times will the outer loop run in the example triangle printing program?

3
5
7

💡 Hint: Count how many iterations the outer loop is set.

Question 2

The inner loop's execution is determined by which variable?

Outer loop variable
Inner loop variable
Neither

💡 Hint: Which loop affects the other?

1 more question available

Challenge Problems

Push your limits with advanced challenges

Challenge 1 Hard

Create a program that uses nested loops to print a series of increasing and decreasing triangles. How would you implement this?

💡 Hint: Consider different conditions for the outer loop.

Challenge 2 Hard

Modify the triangle printing example to also print each line number preceding the stars. How would that affect your nested loop?

💡 Hint: What additional output do you need to include inside the outer loop?

Get performance evaluation

Reference links

Supplementary resources to enhance your learning experience.