While loop _do_while Loop _switch

Source: Internet
Author: User

Swith Syntax:

Switch (value)

{

Case value 1:

Statement

Break

Case Value 2:

Statement

Break

Case Value 3:

Statement

Break

Default

Break

}

1, the value matches the case value, matches on the execution corresponding statement, does not match on executes the default

2. Note Colon and semicolon

3, pay attention to the use of break

While syntax:

Initial

while (loop condition)

{

Loop body

State change

}

1, easy to forget the state change

2, while nesting easy to forget the initial conditions

Do_while Syntax:

Initial

Do

{

Loop body

State change

}while (cyclic conditions);

1, regardless of whether the cycle conditions are satisfied to perform the cycle of the body

2, plus semicolon

3. Do not forget the state change and initial conditions

While loop _do_while Loop _switch

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.