Chapter 3 C
Chapter 3 C
Arithmetic Operators
Assignment Operators
Relational Operators
Logical Operators
Operators and Expressions
Arithmetic Operators
Unary plus and unary minus
Binary arithmetic operators
Division in C
✓ Integer division: C performs integer division if both operands are integer type.
Integer division always evaluates to an integer discarding the fractional part.
✓ Real division: C performs real division if any of the two operands are real type
(either float or double). Real division evaluates to a real value containing
integer as well as fractional part.
Remainder/Modulo division
Operator % evaluates remainder after performing division of two numbers.
Important note:
•Modulo division is only possible with integer
operands. It causes compilation error with
float types.
•Modulo operator returns sign of the first
operand.
Assignment
Assignment operator is used to assign value to a variable (memory
location). It evaluates expression on right side of = symbol and assigns
evaluated value to left side the variable.
Assignment
Assignment operator is used to assign value to a variable (memory
location). It evaluates expression on right side of = symbol and assigns
evaluated value to left side the variable.
Compound
Increment and Decrement operator in C
(compound assignment)
Prefix vs Postfix
Prefix first increment/decrements its value then returns the
result. Whereas postfix first returns the result then
increment/decrement the value.
Prefix vs Postfix
Precedence of operators