An infiniteloop -- sometimes called anendless loop -- is a piece ofcode that lacks a functional exit so that it repeats indefinitely. In computer programming, a loop is a sequence ofinstructions that is continually repeated until a certain condition is reached.
Infinite loops can be used intentionally or can occur as the result of a programming error or abug. A pseudo-infinite loop is one that looks as if it will be infinite but stops at some point.
The term infinite loop is sometimes used to describe an endless iteration situation inDevOps feedback loops and software development processes.
A loop in computer programming is created when a sequence of instructions repeats until a certain terminating condition is reached. Typically, a definedprocess is completed -- such as getting an item of data and changing it -- and then a condition is checked, such as whether a counter has reached a prescribed number. Once the prescribed number is reached the loop ends.
Loops are used to execute the same code multiple times. For example, code that checks the attendance status of each student in a classroom could return a Y for present and an N for absent. The program would need to run through the class roster of 26 students and do this for each member of the class. The program's stopping condition would occur after 26 students had been checked.
There are different types of loops, anddifferent programming languages have different loop syntaxes. Some types of loops include the following:
No matter the loop type or language syntax, most loops have an exit condition that tells the loop when to end.
Infinite loops continue as long as theexit condition doesn't occur. A loop without an exit condition happens when one of the following conditions exists:
In the attendance checking program example, the 26 students are listed in alphabetical order and labeled numerically, with the first student on the list being number one and the last student being number 26. In this case, the loop would normally be set to terminate after the loop runs 26 times. However, the following criteria could turn it into an infinite loop:
In all cases, if the presence of the specified condition cannot be ascertained, the next instruction in the sequence tells the program to return to the first instruction and repeat the sequence. This typically continues until the program terminates automatically after a certain amount of time, or the operating system (OS) terminates the program with an error.
An infinite loop often results from a programming error. For example, the conditions for exit are incorrectly written.
However, there are instances when an infinite loop is used intentionally, enabling a program to run continuously. Some examples include the following:
The following joke captures the spirit of infinite loops such as malware:
The programmer, thinking like a computer, presumably lathered and rinsed repeatedly until they died of exhaustion, starvation or drowned.
The following is an example of infinite loop code inPython:
i=1while i <= 7print ("still looping")In this loop, the program checks the value of i, then says that if i is less than or equal to 7, the program will print the phrase "still looping." The exit condition is if i is greater than 7. Since there is nothing changing the value of i, this exit condition cannot be fulfilled. The program will print the phrase "still looping" indefinitely until the computer is shut off or crashes.
Infinite loops can appear in a variety of computing contexts and are used in a variety of programming languages. In some contexts, loop conditions can cause a cybersecurity breach. Cybersecurity professionals shouldlearn these 5 essential programming languages to be able to stop these threats and others effectively.
6G (sixth-generation wireless) is the successor to 5G cellular technology and is expected to be globally available by around 2030. See More.
6G (sixth-generation wireless) is the successor to 5G cellular technology and is expected to be globally available by around 2030.
A phase-locked loop (PLL) is an electronic circuit with a voltage or voltage-driven oscillator that constantly adjusts to match ...
Time-Sensitive Networking (TSN) is a set of IEEE 802.1 standards that transform traditional Ethernet into a deterministic, ...
No longer just a good idea, IAM is a crucial piece of the cybersecurity puzzle. It's how an organization regulates access to ...
Data masking is a security technique that modifies sensitive data in a data set so it can be used safely in a non-production ...
Antivirus software (antivirus program) is a security program designed to prevent, detect, search and remove viruses and other ...
A chief data officer (CDO) in many organizations is a C-level executive whose position has evolved into a range of strategic data...
User-generated content (UGC) is published information that an unpaid contributor provides to a website.
Business process outsourcing (BPO) is a business practice in which an organization contracts with an external service provider to...
Compensation management is the discipline and process for determining employees' appropriate pay, incentives, rewards, bonuses ...
HR technology (human resources tech) refers to the hardware and software that support an organization's human resource management...
Core HR (core human resources) is an umbrella term that refers to the essential, mandatory and fundamental tasks and functions of...
A virtual agent is an AI-powered software application or service that interacts with humans or other digital systems in a ...
Customer acquisition cost (CAC) is the cost associated with convincing a consumer to buy your product or service, including ...
Direct marketing is a type of advertising campaign that seeks to elicit an action (such as an order, a visit to a store or ...
