–=
Subtract the value of the second operand from the value of the first operand; store the result
in the object specified by the first operand.
<<=
Shift the value of the first operand left the number of bits specified by the value of the
second operand; store the result in the object specified by the first operand.
>>=
Shift the value of the first operand right the number of bits specified by the value of the
second operand; store the result in the object specified by the first operand.
&=
Obtain the bitwise AND of the first and second operands; store the result in the object
specified by the first operand.
^=
Obtain the bitwise exclusive OR of the first and second operands; store the result in the
object specified by the first operand.
=
Obtain the bitwise inclusive OR of the first and second operands; store the result in the
object specified by the first operand.
?: Conditional operator
Condition
?
true statement
:
false statement
;
Example
Cout<<(marks > 60 ? “PASS” : “FAIL”);
Char Grade;
Grade = marks > 60 ? ‘P’ : ‘F’;
Bool result;
Result = marks > 60 ? True : false;
Sizeof Operator
The
sizeof
operator gives the size of its operand
Syntax: sizeof
(
typename or variable or Expression
)
The operand to
sizeof
A type name : the name must be enclosed in
parentheses.
cout << sizeof(int);
An expression: can be specified with or without the
parentheses.
int phone_number;
cout << sizeof
phone_number;
cout << sizeof
(phone_number);
Comma Operator
The comma operator (,) is used to separate two or more
expressions that are included where only one expression is
expected. When the set of expressions has to be evaluated for a
value, only the rightmost expression is considered.
For example, the following code:
a = (b=3, b+2);
Would first assign the value 3 to b, and then assign b+2 to
variable a. So, at the end, variable a would contain the value 5
while variable b would contain value 3.
Bit wise Operators
The bitwise operators are:
Bitwise AND
&
Bitwise exclusive OR
^
Bitwise inclusive OR

Operator
Name
Description
a
&
b
and
1 if both bits are 1. 3 & 5 is 1.
a

b
or
1 if either bit is 1. 3  5 is 7.
a
^
b
xor
1 if both bits are different. 3 ^ 5 is 6.
You've reached the end of your free preview.
Want to read all 21 pages?
 Fall '18
 Zia Ul Rehman
 Programming constructs, Bitwise operation