C C++ Java Data Structure Python JavaScript CSS Ajax PL/SQL PHP Puzzles C programs C++ programs Java programs

Home » C programs

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.








COMMENTS