Ads 468x60px

Thursday 1 November 2012

Operators

Assignment Operator

= (equals to)
This operator is used to assign value to a variable. 
e.g. a = 5;
In this case the variable a assigned by the value 5. 


Arithmetic Operators 

+ Addition
- Subtraction
* Multiplication
/ Division
% Modulo

The first four operators works same as they work in mathematics. 
% is used to find the remainder but it can't be used for decimal value. 
e.g.
4%3=1
8%2=0
but in case when nominator will be greater than denominator then it will return the nominator. 
e.g.
3%4=3
2%5=2

Relational Operator

< Greater than
<= Greater than equal to
> Less than
>= Less than equal to
= = Equal to equal to
!= Not equal to

These operator used to compare two expression, the result can only be true or false.
e.g.
3<1 false
3<=3 true
3>6 true
7>=7 true
8= =9 false
9!=10 true

Logical Operators

&& AND All the conditions must be true
|| OR Any single conditions must be true
! NOT Evaluates the opposite boolean value

e.g.
(5 = = 5 )&& (8>4) True
(9 = = 7) || (9>7) True
! (4 = = 3) True

Share if you liked this Post using your favorite sharing service:

Subscribe Updates, Its FREE!

0 comments:

Post a Comment

 
Related Posts Plugin for WordPress, Blogger...