Before moving forward we have to learn some basic concepts which help us in practical programming:
OPERATORS:
These are basically symbols that perform operations on operants.
TYPES:
There are 4 main types:
1 1. Assignment
2 2. Mathematical
3 3. Logical
4 4. Relational
a. Assignment operator:
Operators which assigns value to data names
For example:
X=3, here X is data name and 3 is its value
Syntax:
(dataname)=expression(operators and aperants)
b. Mathematical operators:
The operators which perform manipulations and calculations
Symbol:
+, -, %, /, *
For example:
20-13%2/6*2+4=?
Order:
1. ( )
2. * / % (left to right)
3. + - (left to right)
Note: in one step only one step is performed
C. Relational:
Which relate different things
Symbols:
>=, >, <, <=, ==, !=, <>
d. logical operators:
which are either true or false
there are 3 logical operators:
AND, OR, NOT
NOT will reverse the value
AND will be true only all conditions have value true
OR will be true only one condition is true
NOT is unary operator and AND and OR are binary operators
truth table:
OP1
|
OP2
|
AND
|
OR
|
NOT of OP1
|
T
|
T
|
T
|
T
|
F
|
T
|
F
|
F
|
T
|
F
|
F
|
T
|
F
|
T
|
T
|
F
|
F
|
F
|
F
|
T
|
Comments
Post a Comment