Black Horse programmer _ program Process Control

Source: Internet
Author: User

1. What is process control of a program?

 

1. Syntax format

18) {// a relational operator is involved here

 

The above program is to judge whether the user input age is greater than or equal to 18. If the result is true, enter the adult result on the console; otherwise, execute the statement in else, the output has no adult results, and the above program is not rigorous. For example, the user is not judged for illegal characters, but here I only want to explain the use of the if and else syntax, those will be ignored and will be analyzed in detail when exceptions are mentioned;

 

Comparison operators (also known as Relational operators ):

Operator Example Result

This is the same as the judgment in mathematics, but the symbol here has changed. It should be noted that the equal operator is "=" rather than "= ", this "=" is a value-assigned symbol in c #, which is easy to make mistakes when making judgments;

Conditional boolean operator:

Operator Example Result

Here is a note, that is, the difference between logic and, or, and short-circuit and, or: As long as either side of the operand is false, the value of the entire expression is false, so when it is determined that the left side of the expression is false, short circuit and will no longer judge the value of the right side operand, whether it is true or false, because the result has come out; short circuit or the same, as long as the expression is true on the left, it makes no sense to judge down; so in actual use, both short and, or are used.

2. deformation format

 

 

3. switch, case structure usage

1. Syntax format

2. default rules

 

4. Use of loop statements

1. while Loop

 

// Note that there is a semicolon, which cannot be used.

 

4. Loop other end Methods

 

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.