C Language: If statement

Source: Internet
Author: User

/*

The first: If a conditional expression is set, execute the parentheses after the curly braces

if (conditional expression) {

Statement

...

}

The second type: if the conditional expression is true, execute if the statement in curly braces after the parentheses is executed, or else the statement in the curly braces after the

At least one code here will be executed

if (conditional expression) {

Statement

...

}else{

Statement

...

}

The third type:

if (conditional expression) {

Statement

....

}else if (conditional expression 2) {

Statement

....

}else if (conditional expression 3) {

Statement

....

}

....

else{

Statement

....

}

Features: 1. Only one block of code can be executed in so many blocks

2. When the program executes the conditional expression 3, it indicates that all the expressions in front of it are not valid.

3. If there is else in the IF statement then a block of code will be executed to

Features of the IF statement:

If statement: 1, both are the IF start

2. There can be any other else if

3. There can be at most one else statement

4. If there is only one statement following the IF statement, the curly braces after the if can be omitted (usually development is not done)

If nesting: If statements can be nested inside other if statements

Summary: If statement is also a statement, as long as can write the statement where can write if statement

if (conditional expression) {

Statement

..

if (conditional expression) {

Statement

...

}

Statement

....

}

*/

C Language: If statement

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.