文档介绍:第3章简单的算术运算
和表达式
本章学习内容
算术运算符
增1和减1运算符
宏常量与 const常量
表达式与赋值中的自动类型转换
强制类型转换运算符
常用的标准数学函数
运算符( Operator )
详见附录C
常见的运算符
算术运算符
赋值运算符
类型强转
关系运算符
逻辑运算符
增1和减1
位运算符
(Operator and Expression)
Example:
W + Z
操作数(Operand)
运算符(Operator)
操作数(Operand)
何谓运算符和操作数?
Addition (+)
Subtraction (-)
Multiplication (*)
Division (/)
Modulus (%)
Arithmetic Operators
除法(Division)
Example:
W / Z
浮点数除法
(Floating Division)
W or Z or both are floats
整数除法
(Integer Division)
W and Z are integers
Example:
an integer
an integer
the result is also an integer
整数除法(Integer Division)
11 / 5 = 2
Example:
实数除法(Floating Division)
/ 5 =
a float
an integer
the result is a float
求余(Modulus)
It returns the remainder that occurs after performing the division of 2 operands
Rule:
操作数必须是整数
Operands must be integers
注意!
Example:
11 % 5 = 1
an integer
an integer
the result is the remainder of 11/5
11
5
2
10
1
remainder
result
求余(Modulus)