Section 2 Branch Structure

Source: Internet
Author: User
Tags case statement
  1. In program development, the branch structure is used more frequently than the loop structure, with 10 branches and 4 loops.

  2. Three scenarios of Program Development: Branch, loop, and branch

  3. (1)

    Three formats of if:

    Int A = 10;

    If (A> O)

    {




    Printf ("% d",)

    }

When the condition expression is true or true, execute the statement in braces. Otherwise, execute the statement after if.

(2)

Char sex = 0;

Printf ("Enter your gender: m or F ");

Scanf ("% C", & sex );

If (sex = 'M '){

Printf ("male ");

} Else {

Printf ("female ");

}

(3)

If (){

.......

} Else if (){

.......

} Else if (){

......

} Else {

......

}

4 Relational operators <,>, >=, <=, = ,! =

5 logical operators & |! Note the short circuit of the expression.

6. Operator A> B? A: B

7 switch (){

Case __:

...........

Break;

..........

Default:

Break;

}

Select one more and use the switch... case statement. Pay attention to the break statement.

8. If the break statement is not met, the statement is executed in sequence. After the break statement is met, the switch is jumped out and the statement after braces is executed.

This article from "a long time back to one" blog, please be sure to keep this source http://lulun426.blog.51cto.com/9197884/1533984

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.