"C Programming Language: Modern Methods (2nd Edition)" Chapter 5 select statement

Chapter 5 select statement

It should not be to the ingenuity and logical analysis to judge a programmer, but by its comprehensive analysis of the problem.

Although the C language has many operators, but it has relatively few statements. So far, we have only seen two kinds of statements: return statement (section 2.2) and expression statement (Section 4.5). According to the statement of the impact on the execution order, the rest of the C language statements mostly belong to the following three categories.

  • Select statement (Selection of Statement) . if statement and switch statement allows a program to select a particular set of execution path options.
  • Repeat statement (the Iteration of Statement) . while statement, do statements, and for statements support repeat (loop) operation.
  • Jump statements (Jump of Statement) . break statement, continue statement and goto statement causes an unconditional jump to a location in the program. (Return statement also fall into this category.)

There are other two types of statements in C language, a class is a compound statement (the combination of a few statements into statements), one is null statement (no action).

This chapter discusses the selection and Compound Statements. (Chapter 6 will introduce duplicate statements, a jump statement and empty statement.) Before using the if statement, we need to introduce logic expressions: Conditional if statements can be tested. Section 5.1 describes how relational operators (<, <=,>, and> =), equality has operator (== and! =) And logical operators (&&, ||, and!) Configured logical expressions. Section 5.2 describes the if statements and compound statements, as well as the conditional operator can test a condition in expression (? :). Section 5.3 describes the switch statement.

Guess you like

Origin www.cnblogs.com/shenhuanjie/p/11453723.html