Notes 231212 151401
Notes 231212 151401
SOLVING
IMPLEMENTATION OF OPERATORS AND
EXPRESSION IN PROGRAMMING
COURSE OUTCOMES
x-y
Operand Operand
(x) (y)
Operator
(-)
DEFINITION OF OPERATORS & OPERANDS
OPERATOR
• An operator is a symbol that tells the compiler to perform specific
mathematical or logical functions
OPERANDS
• An object on which an operation is performed; it
receives an operator’s action
• Can consist of constants, variables and expression
OPERATORS
PREFIX
When ++ is used as PREFIX (like ++x), ++x
will increment the value of x and then
return it.
POSTFIX
When ++ is used as POSTFIX (like x++),
operator will return the value of operand
first and then only increment it.
EXAMPLE PROGRAM | PREFIX VS POSTFIX
Output
?
BINARY OPERATOR
x = 10, y = 20, z = 30
1) x * y + z = ?
2) X * (y + z) = ?
Output
ASSIGNMENT OPERATORS
Output?
…ASSIGNMENT OPERATORS : TYPE CASTING
Output?
…ASSIGNMENT OPERATORS : TYPE CASTING
1
Output?
Output?
RELATIONAL OPERATORS
x>y
• Here, > is a relational operator. If x is greater than y,
x>y returns 1 if not then, it returns 0.
• Relational operators are used in decision making and loops
in C programming.
RELATIONAL OPERATORS
Tru Fals
e e
…RELATIONAL OPERATORS
For
example:
c=(c >0) ?10:-10