0% found this document useful (0 votes)
23 views

Nestedloop

This document discusses nested loops, break, and continue statements in C++ loops. It defines nested loops as loops within other loops, where the inner loops restart each time the outer loop repeats. It explains that break immediately terminates the current loop, while continue skips the rest of the current loop iteration. An activity is included to trace sample programs using nested loops, break, and continue using a table. The next topic will be arrays in C++.

Uploaded by

Ameenat naz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Nestedloop

This document discusses nested loops, break, and continue statements in C++ loops. It defines nested loops as loops within other loops, where the inner loops restart each time the outer loop repeats. It explains that break immediately terminates the current loop, while continue skips the rest of the current loop iteration. An activity is included to trace sample programs using nested loops, break, and continue using a table. The next topic will be arrays in C++.

Uploaded by

Ameenat naz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Loop in C++

By
Anam Javaid

COMSATS University Islamabad, Wah Campus


Previous Lecture Outline

For loop
While and do while loop
Lecture Outline
Nested loop
Break
Continue
Nested Loops
• A loop can be nested inside another loop.

• Nested loops consist of an outer loop and one or more inner loops

• Each time the outer loop is repeated, the inner loops are
reentered, and started anew.
Code
Activity
Show the output of the following programs. (Tip: Draw a table and list
the variables in the columns to trace these programs.)
Activity
Break and continue
• The break and continue keywords provide additional controls in a
loop.
• You have used the keyword break in a switch statement.
• You can also use break in a loop to immediately terminate the loop.
Using break in a Nested Loop
• In a nested loop, the break statement only interrupts the loop it is
placed in.
Next Lecture

Arrays in C++

You might also like