Objective C nested loops Objective C

What are nested loops in Objective C?

The use of one loop inside another loop is allowed in Objective C programming language. Some of the examples are used to illustrate the concept.

Syntax:
The syntax for a nested for loop in C Programming is as follows:


The syntax for a nested while loop statement in Objective-C programming language is as follows:

The syntax for a nested do...while loop statement in Objective-C programming language is as follows:

Note: Any type of loop can be put inside of any other type of loop.
For example, a for loop can be inside a while loop or vice versa.

Example:

The following program uses a nested for loop to find the prime numbers from 2 to 100:

The above code is compiled and executed and produces the following result:

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Objective C Topics