Some time, may need to perform the same piece of code repeatedly. Usually, sentences are fulfilled in order: the first sentence in the function is fulfilled first, followed by the second sentence, and so on.
Programming language provides a variety of control structures that promise a more cluttered approach to fulfillment.
Cyclic sentences promise us to perform a sentence or sentence group repeatedly, the following is the usual form of cyclic sentences in most programming words:
Infinite loops
If the condition is permanently not false, then the loop becomes an infinite loop. The For loop can be used in the traditional sense to implement an infinite loop. Because any of the three expressions that make up a loop are not required, you can leave some conditional expressions blank to form an infinite loop.
#include
using namespace Std;
int main ()
{
for (;;)
{
printf ("This loop would run forever.\n");
}
return 0;
}
When a conditional expression does not exist, it is assumed to be true. You can also set an initial value and an increment expression, but typically, C + + programmers tend to use the for (;;) structure to indicate an infinite loop.
Note: You can press Ctrl + C key to stop an infinite loop.
About C + + loops