# C Programming Examples on Bitwise Operations

Here is the listing of C Programming examples on Bitwise Operations.

## 1. C Examples on Mathematical Applications using Bitwise Operations

The C programs in this section which checks whether the given integer has an alternate pattern. It also focuses on rounding the floor of an integer to the next lower power of 2 with and without using bitwise operations, displaying the range of basic data types and the program which uses a function to return the Most Significant Bit position of an unsigned integer.

## 2. C Examples on Integer Bits

The C programs in this section deals with the bits of a given integer. The section contains the programs which check if all the bits of a given integer are 1s, to count the number of bits set to 0 in an integer, to count the number of trailing 0s and leading 0s in an integer, to find the next higher value of N with same 1s and to find the highest bit set for any given integer.

## 3. C Examples on Swapping and Replacing Integers

This section contains C programs that illustrate swapping ith and jth bits for a 32-bit integer, swapping two integers without using temporary variables and bitwise operations, checking if a given integer is a power of 2 using bitwise operators. It also has programs which replaces bits in integer from specified positions from another integer and bits in integer x from bit position a to b from another integer y and a program which takes byte as input and returns all the bits between given positions.

## 4. C Examples on String Positions

This section contains C programs to find the position of string of 1s in a number for a given length and a program to check if nth bit in a 32-bit integer is set or not.

## 5. C Examples on Binary Addition and Reversal of Bits

The C programs in this section illustrate binary addition of strings and reversing of the bits of an 32-bit integer using certain bitwise operations.

C Program to Perform Binary Addition of Strings and Print it C Program to Reverse all the Bits of an 32-bit Integer using Bitwise |

## 6. C Examples on Counting and Swapping the Contents of Strings using Bitwise Operations

The C programs in this section perform counting, swapping and identifying the missing number in an integer array of a given size. The program also determines if the given number is a palindrome or not using bitwise operator.