C Basic Knowledge "cycle"

Source: Internet
Author: User

C Cycle
1. Sometimes, we may need to execute the same piece of code multiple times. In general, statements are executed sequentially: The first statement in a function executes first, followed by the second statement, and so on.
Programming languages provide a variety of control structures for more complex execution paths.
The loop statement allows us to execute a statement or group of statements multiple times.
2. Loop type
The C language provides the following types of loops. Click the link to see the details for each type.
Circular type description
While loop repeats a statement or statement group when the given condition is true. It tests the condition before executing the loop body.
The For loop executes a sequence of statements several times, simplifying the code that manages the loop variable.
The Do...while loop is similar to the while statement except that it is a test condition at the end of the loop body.
Nested loops you can have in while, for, or do: Use one or more loops within a while loop.
3. Circular control Statements
The loop control statement changes the order in which your code executes. Through it you can implement the code jump.
C provides the following loop control statements. Click the link to see the details of each statement.
Control Statement Description
The break statement terminates the loop or switch statement, and the program flow continues to execute the next statement immediately following the loop or switch.
The continue statement tells a loop body to stop the loop iteration at once and restart the next iteration of the loop.
The goto statement transfers control to the marked statement. However, it is not recommended to use a goto statement in a program.

C language Basics Loop

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.