Introduction To Computer Programming With C Language: Operators and Constants
Introduction To Computer Programming With C Language: Operators and Constants
Operators
Mahit Kumar Paul
Assistant Professor, Dept. of CSE
RUET, Rajshahi-6204
mahit.cse@gmail.com
2023-10-08 1
Constants and Literals
• Constants refer to fixed values that the program may
not alter during its execution.
2023-10-08 2
Defining Constants
Using #define Preprocessor
2023-10-08 5
Defining Constants-Example
Example
2023-10-08 9
Arithmetic Operators
• Assume variable A holds 10 and variable B holds 20
2023-10-08 10
Relational Operators
• Assume variable A holds 10 and variable B holds 20
2023-10-08 11
Logical Operators
• Assume variable A holds 52 and variable B holds 0
2023-10-08 12
Logical Operators…
Example
2023-10-08 14
Bitwise Operators-Example
Example
2023-10-08 15
Bitwise Operators-Example…
Output
2023-10-08 16
Assignment Operators
2023-10-08 17
Assignment Operators…
2023-10-08 18
Other Operators…
2023-10-08 19
Sizeof() Operator
Output:
Value = 9
2023-10-08
Memory byte of z = 4 20
& Operator
Output: Value = 9
Memory byte of z = 4
Syntax
2023-10-08 22
?: Operator…
Example
• The following program prints the biggest number
between two integer numbers.
Output: Value of z = 7
2023-10-08 23
Operator Precedence and Associativity
• Operator precedence helps us determine which of the
operators in an expression must be evaluated first in case
the expression consists of more than a single operator.
2023-10-08 25
Operator Precedence and Associativity…
2023-10-08 26
2023-10-08 27