c ++ Study Notes 8

(Viii) expressions and arithmetic operations

(I) introducing operators and expressions

⑴ calculation equation by the operator and expression objects is called.


(In addition to the result of the expression of the determined values, and determining the type of data)

Operators commonly classified ⑵c ++

The properties of operations:

Arithmetic operators: * - + /%
increment and decrement: ++ -
assignment operator: + == = = * / =% =
relational operators:> <= ==> = <=!
Logic operation symbol:! || &&
......

The number of operands:

Unary (operand)
The opposite takes :-()! ++ and so on.
Binary operator (two operands)
as:% = + + = / => && like.
Ternary operator (three operands)
as:? : () (Conditional operator)
......

(I) the expression operands can be a constant, variable, function calls and nested expressions.

⑴ arithmetic expressions: (ab &) / C 2 15% + -4 + sqrt (4.0);
⑵ increment expression: A ++ (+ A = A. 1);
⑶ compound assignment expressions: A
=. 1-B (A A * = (. 1-B));
⑷ relational expression: A + B> C + D, A> B> C;
⑸ logical expression: a> b && b> c .

(Ii) the operator of the operation sequence of the expression

[C language, which has several operators, how the priority order]
https://mr.baidu.com/teso72h?f=cp&u=57ccf80650912f4c

(Iii) The operator of the expression sequence of operations
The same priority, how to determine the order of operations?

Using binding operators.
Right binding (right to left calculation), as unary operators, assignment operators, the conditional operator;
left binding (calculated from left to right), as binary operators.
Intelligent use of parentheses operation order may be changed from the operator --- out.

(Iv)% for integer data

Such as: 5 = 5,100% 4% 6% 4 = 0,9 = 1,9 = 1% -4, -9% 4 = -1, -1 = -9% -4
operands sides operator binocular to the same type;
the use of the function, to be noted that the data type.

(V) calculating an absolute value of a data, and computing the square root and expression.

summary

Categories ⑴ operator;
described legitimate expression ⑵;
priority ⑶ operator;
⑷ operator binding;
⑸ * Multiplier arithmetic expression can be omitted;
⑹% and arithmetic /, the data type is positive number.

Guess you like

Origin www.cnblogs.com/cooller-code/p/12297038.html