Скачать презентацию
Идет загрузка презентации. Пожалуйста, подождите
Презентация была опубликована 9 лет назад пользователемТимофей Грохольский
1 Operators and Arithmetic Operations
2 Operators An operator is a symbol that instructs the code to perform some operations or actions on one or more operands. C operators are categorized to several types: assignment operator assignment operator mathematical operators mathematical operators relational operators relational operators logical operators logical operators
3 Assignment Operator The assignment operator which is the equal sign ( = ). If you write c = y in a C program, the value of y is assigned to c. In assigning, the right side can be any expression and the left side must be a variable name.
4 Mathematical Operators C mathematical operators can be classified into two: unary and binary Binary operators Mathematical operators perform math operations such as: addition ( + ), subtraction ( - ), multiplication ( * ), division ( / ) and modulus ( % ). addition ( + ), subtraction ( - ), multiplication ( * ), division ( / ) and modulus ( % ).
5 Mathematical Operators Unary operators C has two unary operators: the increment and the decrement Prefix or infix = ++x for increment and - - x for decrement Postfix = x++ for increment and X - - for decrement
6 Operator Precedence An expression contains more than one operator. The order in which operations are performed pose a significance. This order is called operator precedence. Operations with higher precedence are performed first when an expression is evaluated. Operators Relative Precedence Operators Relative Precedence * / %2 + -3
7 If an expression contains more than one operator with the same precedence level, the operators are performed in left to right order as they appear in the expression. C also uses parentheses to modify the evaluation order. A sub expression enclosed in parentheses is evaluated first without regard to operator precedence.
8
Relational Operators OperatorSymbolExample Equal==X==A Not equal !=A!=0 Less than
9 Logical Operators OperatorSymbolExample and&& var1 & & var2 or|| var1 | | var2 not!!var1
Еще похожие презентации в нашем архиве:
© 2024 MyShared Inc.
All rights reserved.