📜  Arduino-控制声明

📅  最后修改于: 2020-11-05 03:27:18             🧑  作者: Mango


决策结构要求程序员指定一个或多个要由程序评估或测试的条件。如果确定条件为真,则应与要执行的一个或多个语句一起;如果确定条件为假,则应与要执行的其他语句一起。

以下是大多数编程语言中常见的典型决策结构的一般形式-

做决定

控制语句是源代码中控制程序执行流程的元素。他们是-

S.NO. Control Statement & Description
1

If statement

It takes an expression in parenthesis and a statement or block of statements. If the expression is true then the statement or block of statements gets executed otherwise these statements are skipped.

2

If …else statement

An if statement can be followed by an optional else statement, which executes when the expression is false.

3

If…else if …else statement

The if statement can be followed by an optional else if…else statement, which is very useful to test various conditions using single if…else if statement.

4

switch case statement

Similar to the if statements, switch…case controls the flow of programs by allowing the programmers to specify different codes that should be executed in various conditions.

5

Conditional Operator ? :

The conditional operator ? : is the only ternary operator in C.