Sub-number Han number & #183; C Language -- Condition Statement and C language statement

Source: Internet
Author: User

Number of sub-classes · C language-condition statements and C language statements

First of all, let's talk about the theoretical knowledge. There are three structures in programming: sequential structure, conditional structure, and cyclic structure. If they are expressed using flowcharts:

In C, how can we use these three structures flexibly? This requiresControl statement.

WhileCondition StatementIs one of the control statements.

Generally, there are three condition statements in C language:IfStatement,If ...... ElseStatement andSwitchStatement

Next we will introduce the three statements respectively.

 

I. if statement

(Use the if statement to implement a branch of the above condition structure)

 

II. if ...... Else statement

(If ...... The else statement implements the above conditional structure)

 

Iii. switch statements

(Now we use the switch statement to implement an input number and output its corresponding notes)

 

Conclusion: The if statement only determines if yes;

If ...... The else statement not only determines the yes condition, but also determines the no condition;

The switch statement determines a specific situation and its exceptions.

When compiling a C program, select the appropriate condition statement to achieve the designed effect.

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.