Loop Structure program design, structure Program Design

Source: Internet
Author: User

Loop Structure program design, structure Program Design

The main contents include:

For Loop Structure

For statement format:

For (initialization expression; conditional expression; Incremental expression)

Loop body statement Block

Where:

1. Initialization expression: It is generally a value assignment expression, which is usually used to assign an initial value to the cyclic variable. Loop variables control whether or not the loop is executed. If an initial value is assigned to the loop variable outside the for statement, this expression can be omitted.

2. conditional expression: it is usually a cyclic condition, usually a relational expression or a logical expression.

3. incremental expression: it is usually used to modify the value of the cyclic variable, which is generally a value assignment statement. Controls the direction in which the variable changes after each loop.

 

The for statement execution process is:
(1) calculate the value of the initialization expression.

(2) calculate the value of the conditional expression. If the value is true (not 0), execute the statement in the loop body and convert it to (3). If the value is false (0), convert it to (4 ).

(3) calculate the value of the incremental expression and convert it to (2) Repeated execution.

(4). End the 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.