About C + + loops

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.