Expression
Combination of operator and operand is
called expression
• Operand can be variable or constant
• Operator is symbol used for some
operation.
Operands
area = PI * r * r;
Operator
Operator
Operator is special symbol used for some
operation
Categories of Operators
Based on number of operand there are
three kind of operator
❑Unary Operator
❑Binary Operator
❑Ternary Operator
Types of Operator
Arithmetic Operators +, -, *, / , %
Relational Operators <, >, <=, >=, ==, !=
Logical Operators &&, ||, !
Increment / Decrement
Operators
++ , --
Compound Assignment +=, -+, *=, /=, %=
Conditional Operator ? :
Arithmetic operators:
Rules of operator precedence
Arithmetic Expressions: True or False
• Arithmetic expressions evaluate to
numeric values.
• An arithmetic expression that has a value
of zero is false.
• An arithmetic expression that has a value
other than zero is true.
Practice with Arithmetic Expressions
● int a = 1, b = 2, c = 3 ;
● float x = 3.33, y = 6.66 ;
● Expression Numeric Value True/False
● a+b
● b-2*a
● c-b-a
● c-a
● y-x
● y-2*x
Arithmetic Assignment Operators or
Compound Assignment Operators
▪ The general form of an arithmetic assignment operator is
v op= exp
▪ Where v is a variable and op is a binary arithmetic operator. This
statement is equivalent to v = v op (exp)
▪a = a + b can be written as a += b
▪a = a * b can be written as a *= b
▪a = a / b can be written as a /= b
▪a = a - b can be written as a -= b