Operators
Assignment operators
(In
C) are use to assign a value to a variable and that operator is “=”. Remember that we can’t put
expressions on left hand side of any assignment operator. X=X+1=X’s old value + 1
Arithmetic operators
(In C) are used for
Arithmetic operations (Remember that
right hand side of = is not effected by the operation) and only the
following operators are use for Arithmetic operations:
Purpose
How to use the operators in C
1) + for addition X= 1 + 2 = 3
2) – for subtraction Y
= 2 – 1 = 1
3) / for dividing Z
= 4 / 2 = 2
Note:
Dividing by 0 is illegal and if division is of integers then
fractional part of that division will truncate. All unknowns are variables
4) * for multiplication J = 3 * 6 = 1 8
5) % for taking the remainder I = 5 % 4 =
1
Relational operators (In C) are used for any
kind or comparison and only following operator are use:
1) < shows less than
2) > shows greater than
3) = = shows equal to
4) != shows not equal to
5) <= shows less than or equal to
6) >= shows greater than or equal to
Not operators (In C) are used for any kind
of ignorance and they are as follow:
1)!True for
showing false (!(true
condition here))
2)!False for
showing true (!(false
condition here))
Precedence
The brackets are solve first, then *, / and % are
solve, then + and – are solve.
Note:
The
expressions are solve left to right (in C)
Keywords
There are certain
keywords like “main ()”and are a followed:
1) Main ( ) 4)
While ( )
2) If ( ) 5)
Do ( )
3) Else ( ) 6)
For( )
Note:
The style
of writing program is important because it tells program about the group of commands
0 comments:
Post a Comment