Three control structures

Source: Internet
Author: User
Tags switch case

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/202G93b2-0.gif "/> the control structure can be divided into three types:Sequence, branch, and loop

1. Order: statements are executed in sequence.

2. Branch: select to execute different statement blocks according to the conditions.

If else if: mainly for range matching

If (conditional expression)

{

// Statement block executed when the condition is expressed as true.

}

Else

{

// Statement block executed when the condition expression is false.

}

Switch case: Mainly used for single-value matching.
Switch (integer, enumeration, or string variable)
Case constant or literal
Each case should end with break.

Try catch

3. Loop: You can execute some statement blocks repeatedly.

For
While
Do while

Foreach: Read-Only

For:
For (initialization of cyclic variables; conditions for cyclic execution; process of changing cyclic variables)
{
Loop body
}

 

For: This is a cycle in which the number of cycles is determined by the major.
While do while: a loop with an uncertain number of cycles.
Endless loop: for (; true;) while (true)
For (int I = 1; I> 0; I ++)

The following items must be included in the Loop: Initialize the loop variable.
Cyclic execution Conditions
The process of changing cyclic Variables
Loop body

After learning the three control structures, we must make good use of them in subsequent studies to make them practical. 650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/202G93W7-1.gif "/>

This article from the "Lanting drunk beauty" blog, please be sure to keep this source http://7607889.blog.51cto.com/7597889/1263014

Related Article

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.