Download Operators

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
UWU/ SCT/ 20/ 061
Arithmetic Operators
Operation
Syntax
Comment
Result(a=4 , b=2)
Addition
Subtraction
Multipication
Division
Modulus
A+B
A-B
A*B
A/B
A%B
Result = a+b
Result = a-b
Result = a*b
Result = a/b
Result = a%b
6
2
8
2
0
 Relational Operators
Operator
Example
<
>
<=
>=
Result (True=1 , False =0)
True(1)
False(0)
True(1)
True(1)
2<5
2>5
5<=5
4>=2
 Equality Operators
Operator
==
!=
Meaning
Returns true if both operands are equal
Returns true if operands do not have the same
value
Example
1==2
4==4
5!=6
7!=7
Result
False(0)
True(1)
True(1)
False(0)
 Logical Operators
AND (&&)
OR (||)
A
B
A && B
0
0
1
1
0
1
0
1
0
0
0
1
A
0
0
1
1
B
0
1
0
1
A ||B
0
1
1
1
NOT (!)
A
0
1
B
1
0
1
UWU/ SCT/ 20/ 061
Unary Operators
Operator
Unary minus(-)
Unary increment(++)
Unary decrement(--)
Example
-a
++a
--a
Meaning
-(2)
a=a+1
a=a-1
Result
-2
3
1
 Assignment Operators
Example
Meaning
A’s new value
Assignment(=)
Addition assignment(+=)
Subtraction assignment(-=)
Multiplication assignment(*=)
a=20;
a+=2;
a-=2;
a*=2;
20 was assigned to a
a= a + 2;
a= a – 2;
a= a*2;
20
12
8
20
Division assignment(/=)
Modulus assignment(%=)
a/=2;
a%=2;
a= a/2;
a= a%2;
5
0
Operator
2
Related documents