You are on page 1of 6

SEC 3

COMBINED ASSIGNMENT OPERATORS


• +-*/% a=10 , b=5
• a=a*b-2; a*=b-2; a=15 , b=5
• Amount-=4;
• Y*=4;
• Totat/=27; x%=7; x=x%7;
• X+=y*5;
• Total-=dis*4; incr*=salrep*5; profit/=(share-1000)
INCREMENT AND DECREMENT (++ , --)
• If we have k=10; k++; ++k; k--;
Operation Name Example (k=10) Output(y,k)
++ Post incr. y=++k; (11,11)
++ Pre incr. y=k++; (10,11)
-- Post decr. y=--k; (9,9)
-- Pre decr. y=k--; (10,9)
Int X=16 ; //00010000
~x=11101111
Y=17 //00010001
BITWISE OPERATOR Z=x&y // 00010000
Z=x<<1; //00100000

Operator Name
~ Not
& AND
| OR
^ XOR
<< Left Shift
>> Right Shift
RELATIONAL OPERATION
operator Name Example
== Equality (4==5) false
!= Not equal (4!=5) true
<= Less than or equal (3<= 7) true
>= Greater than or equal (3>=7) false
< Less than (4<7) true
> Greater than (5>9) false
LOGICAL OPERATOR
• To join logical expressions / its output (true or false)

Operator Name
! Logical not
&& Logical and
|| Logical or

You might also like