C Bitwose operator
C Bitwose operator
return 0;
15 }
Output
a && b : 1
a || b : 1
!a: 0
4. Bitwise Operators in C
The Bitwise operators are used to perform bit-level operations on the
operands. The operators are first converted to bit-level and then the
calculation is performed on the operands. Mathematical operations such
as addition, subtraction, multiplication, etc. can be performed at the bit
level for faster processing.
1 Performs bit-
by-bit AND
& Bitwise AND operation and a&b
returns the
result.
2 Performs bit-
by-bit OR
| Bitwise OR operation and a|b
returns the
result.
3 Performs bit-
by-bit XOR
^ Bitwise XOR operation and a^b
returns the
result.
https://www.geeksforgeeks.org/operators-in-c/ 8/27
1/26/25, 6:19 PM Operators in C - GeeksforGeeks
5 Shifts the
number in
binary form by
Bitwise
<< one place in a << b
Leftshift
the operation
and returns
the result.
6 Shifts the
number in
binary form by
>> Bitwise
one place in a >> b
Rightshilft
the operation
and returns
the result.
Output
a & b: 1
a | b: 29
a ^ b: 28
~a: -26
a >> b: 0
a << b: 800
5. Assignment Operators in C
Assignment operators are used to assign value to a variable. The left
side operand of the assignment operator is a variable and the right side
operand of the assignment operator is a value. The value on the right
side must be of the same data type as the variable on the left side
otherwise the compiler will raise an error.
1 Assign the
value of the
= Simple a=b
right operand
Assignment
to the left
operand.
https://www.geeksforgeeks.org/operators-in-c/ 10/27