Process control,

Source: Internet
Author: User
Tags case statement

Process control,

Sequence Control:

Allows the program to run in sequence. If no other control statements are encountered, the program runs from left to right and from top to bottom by default.

 

 

Branch Control:

There are three branch control options for execution of the program:

① Single branch if statement

If (conditional expression) {statement ;}

② Dual-branch if-else statement

If (condition expression) {statement;} else {statement ;}

③ Multi-branch if-else if statement

A conditional expression can also be a function. Its final return value is a Boolean value.

After else finds an entry (an expression that meets the condition), the execution will not continue even if other entries meet the condition.

If (condition expression 1) {Statement 1;} else if (condition expression 2) {Statement 2;} else if (condition expression 3) {Statement 3 ;} else {Statement 4 ;}

③ Multi-branch switch-case statement

When the compiler made a mistake in the switch statement, the case flag would only match once, and the matching case would be executed in a dark place. This is a historical issue.

Break indicates that subsequent operations are interrupted and the switch statement exists.

The data type of the conditional expression must be consistent with the constant type of case.

Switch (condition expression) {case constant 1: Statement 1; break; case constant 2: Statement 2; break; case constant n: Statement n; break; default: Statement ;}

Loop Control:

I. for loop operation process

 

Ⅱ while loop: Judge before execution

Iii. do while LOOP execution before judgment

 

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.