Lecture4一C运算符与表达式 绳伟光 微纳电子学系 上海交通大学 2017-03-03 1/67
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Lecture 4 — C 运算符与表达式 绳伟光 微纳电子学系 上海交通大学 2017-03-03 1 / 67
提纲 概念引入 C运算符 算术运算符 赋值运算符 自增/自减运算符 复杂表达式相关问题 关系操作符 逻辑运算符 位运算符 C类型转换 隐式转型 显式转型 类型定义 sizeof运算符 2/67
. .. .. . . .. .. .. . . .. .. .. . . .. .. .. . . .. . . .. .. . 提纲1 概念引入 2 C 运算符 算术运算符 赋值运算符 自增 /自减运算符 复杂表达式相关问题 关系操作符 逻辑运算符 位运算符 3 C 类型转换 隐式转型 显式转型 类型定义 sizeof 运算符 2 / 67
提纲 概念引入 2 C运算符 。算术运算符 。赋值运算符 。自增/自减运算符 。复杂表达式相关问题 。关系操作符 。逻辑运算符 ·位运算符 C类型转换 。隐式转型 显式转型 。类型定义 。sizeof运算符 ¥口,9,¥意¥面20攻C 3/67
. .. .. . . .. .. .. . . .. .. .. . . .. .. .. . . .. . . .. .. . 提纲1 概念引入 2 C 运算符 算术运算符 赋值运算符 自增 /自减运算符 复杂表达式相关问题 关系操作符 逻辑运算符 位运算符 3 C 类型转换 隐式转型 显式转型 类型定义 sizeof 运算符 3 / 67
C运算符与表达式概念引入 o Mathematic Calculation=Mathematic Equation ●Computation→Expression(表达式) o Mathematic Symbol→C Operator(运算符) ·常量(Constants)和变量(Variables)是最简单的表达式 ●运算符+常量/变量→复杂表达式 运算符也被称为操作符,可以混用! 4/67
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C 运算符与表达式概念引入 Mathematic Calculation ⇒ Mathematic Equation Computation ⇒ Expression (表达式) Mathematic Symbol ⇒ C Operator (运算符) 常量 (Constants) 和变量 (Variables) 是最简单的表达式 运算符 + 常量/变量 ⇒ 复杂表达式 运算符也被称为操作符,可以混用! 4 / 67
C运算符种类 o Arithmetic operators:+,-*,/ o Relational operators:>,>=,<,<===,! ●Logical operators:&&,ll,! o Assignment operators:=,+=,-=*=,/ oBit operators:<<>>,&,,~, o Self increment/decrement:++,- o Others(C provides ~50 operators) 5/67
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C 运算符种类 Arithmetic operators: +, −, ∗, /, % Relational operators: >, >=, <, <=, ==, != Logical operators: &&, ||, ! Assignment operators: =, +=, –=, ∗=, /= Bit operators: <<, >>, &, |, ∼, ˆ Self increment/decrement: ++, −− Others (C provides ∼50 operators) 5 / 67