0% found this document useful (0 votes)
92 views3 pages

3.10. Nested Loops

Nested loops are used to solve a variety of programming problems and are an essential part of programming. The example document discusses a nested for loop program that finds the factors of numbers from 2 to 100, with an outer loop running i from 2 through 100 and an inner loop testing all numbers from 2 up to i to print those that evenly divide i. Nested loops are important for programming and this example demonstrates using them to find factors of numbers within a given range.

Uploaded by

cristi25
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views3 pages

3.10. Nested Loops

Nested loops are used to solve a variety of programming problems and are an essential part of programming. The example document discusses a nested for loop program that finds the factors of numbers from 2 to 100, with an outer loop running i from 2 through 100 and an inner loop testing all numbers from 2 up to i to print those that evenly divide i. Nested loops are important for programming and this example demonstrates using them to find factors of numbers within a given range.

Uploaded by

cristi25
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 3

As you know, one loop can be nested inside of another.

Nested loops are used to solve a


wide variety of programming problems and are an essential part of programming.

So, before leaving the topic of Java's loop statements, let's look at one more nested loop
example.

The following program uses a nested for loop to find the factors of the numbers from 2 to
100.
In the FindFac program, the outer loop runs i from 2 through 100.

The inner loop successively tests all numbers from 2 up to i, printing those that evenly
divide i.

Here's a portion of the output produced by the program.


Summary

In this lesson, you learned that loops may be nested.

You also learned that the nested loops are an essential part of any program and can be
used to solve a wide variety of programming problems.

You might also like