Loops
There might be a situation where you might require to run a single block of code a number of times, in that situation, loops come in handy. Loops come handy in situations such as iterating through data structures in any programming language or traversing through large sets of data to filter out junk data, followed by certain keywords followed by alphanumeric characters followed by certain special characters.
Types of loops
There are two types of loops, namely:
- Definite: In this case, the code of block runs for a defined number of times. This is useful when the programmer exactly knows in how many counts the task will be executed or let's assume that he knows the number of elements inside the data structure. For example, the strength of a classroom.
- Indefinite: In this case, the code of block runs until the condition is true. This is useful where the count is unknown. For example, trying to figure out the number of times London appears in a literary article.
Before further delving into...