# C solved programs/examples on Bitwise Operators

This section contains solved programs on Bitwise Operators with output and explanation, here we will learn how and why to use bitwise operators by demonstrating relevant examples.

The operators which we are going to use in these examples are bitwise AND (&), bitwise OR (|), Left shift operator (<<), right shift operator (>>) and more.

## List of bitwise operator example programs in C

Here is the list of some of the C language programs based on Bitwise operators.

1. C program to find Binary number of a Decimal number.
In this C program, we will read an integer (decimal) number and print its Binary values (Binary number).
2. C program to get minimum number of bits to store an integer number.
In this C program, we will find how many minimum bit(s) are required to store an integer number?
3. C program to swap two bits.
Swapping of two bits of a byte using C program: Here, we will learn how to swap two bits of a byte?
4. C program to check whether all bits of a number are UNSET/LOW?
Learn: how we can check that whether all bits of a one byte (8 bits) number are UNSET/LOW using C program? Here, we are implemented the program for this using Bitwise AND (&) operator.
5. C program to swap bytes (for example convert 0x1234 to 0x3412).
Here, we have a number of two byte (short integer) in hexadecimal format and we are going to swap its bytes using C program.
6. C program to reverse bits of a number.
In this C program, we are going to learn how to reverse bits of a number? Here, we have a number and printing its bits value in reverse order.
7. C program to count number of 1's in a number.
In this C program, we are going to learn how to count set bits in a number? Here, we have a number and print total number of 1’s of a number.
8. C program to swap nibbles of a byte/word.
Here, we have a number of one byte in hexadecimal format and we are writing a program to swap its nibbles.
9. C program to demonstrate left shift (<<) operator.
In this C program, we are going to learn how to use bitwise left shift operator? Here is an example, demonstrating the use of left shift bitwise operator.
10. C program to demonstrate right shift (>>) operator.
In this C program, we are going to learn how to use bitwise right shift operator? Here is an example, demonstrating the use of right shift bitwise operator.
11. C program to set/clear (low/high) bits of a number.
In this C program, we are going to learn how to set (make all bits high) and clear (make all bits low) all bits of a number.
12. C program to swap two numbers using bitwise operator.
In this C program, we are going to learn how to swap two integer numbers using bitwise operator? Here we are swapping numbers without using any third variable.
13. C program to Count the Number of Trailing Zeroes in an Integer.
Count the number of trailing zeroes in an integer in C: Here, we are going to see how to use bitwise operators for counting number of trailing zeros in the binary representation of an integer?
14. C program to find the Highest Bit Set for any given Integer.
Find the highest bit set of a number in C: Here, we are going to see how to use bitwise operators tofind the highest bit set in the binary representation of given integer?
15. C program to check if all the bits of a given integer is one (1).
Check if all the bits of a given integer is one (1) using C program: Here, we are going to implement a C program that will check whether all bits of an integer is set/one (1) or not.
16. C program to count number of bits set to 1 in an Integer.
Count number of bit set to 1 in an integer using C program: Here, we are going to implement a C program that will count the total set bits (bits which are set to 1) in an integer number using bitwise operator.
17. C program to check whether a given number is palindrome or not using Bitwise Operator.
Palindrome number check program in C: In this article, we are going to see how to use bitwise operators to find whether a number (binary representation) is palindrome or not?
18. C program to find odd or even number using bitmasking.
In this article, we are going to see how to check a number odd or even using bitwise operators?
19. C program to replace bit in an integer at a specified position from another integer.
In this article, we are going to learn how to replace a bit of a number at a specified position from another number?
20. C program to swap two Integers using Bitwise Operators.
In this article, we are going to see how to swap two no using bitwise operator without using any temporary operators?
21. C program to Check if nth Bit in a 32-bit Integer is set or not.
In this article, we are going to see how to find nth bit of a 32-bit integer is set or not using bitwise operator?

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates