C program to swap two numbers using bitwise operator

Write a C program to input any two numbers from user and swap values of both numbers using bitwise operator. How to swap two number using bitwise operator in C programming. Logic to swap two numbers using bitwise operator in C programming.

Example

Input

Input first number: 22
Input second number: 65

Output

First number after swapping: 65
Second number after swapping: 22

Read more

C program to convert decimal to binary number system using bitwise operator

Write a C program to input any decimal number from user and convert it to binary number system using bitwise operator. How to convert from decimal number system to binary number system using bitwise operator in C programming. Logic to convert decimal to binary using bitwise operator in C program.

Example

Input

Input any number: 22

Output

Binary number: 00000000000000000000000000010110

Read more

C program to count zeros and ones in a binary number

Write a C program to input a number from user and count total number of ones (1s) and zeros (0s) in the given number using bitwise operator. How to count zeros and ones in a binary number using bitwise operator in C programming.

Example

Input

Input any number: 22

Output

Output number of ones: 3
Output number of zeros: 29

Read more

C program to count leading zeros in a binary number

Write a C program to input any number from user and find total number of leading zeros of the given number. How to find total leading zeros of a given number (in binary representation) using bitwise operator in C programming. Logic to count total leading zeros of a given number using C programming.

Example

Input

Input any number: 22

Output

Output leading zeros: 27 (using 4 byte signed integer)

Read more

C program to count trailing zeros in a binary number

Write a C program to input any number from user and count number of trailing zeros in the given number using bitwise operator. How to find total number of trailing zeros in any given number using bitwise operator in C programming.

Example

Input

Input any number: 22

Output

Trailing zeros: 1

Read more

C program to get lowest order or first set bit of a number

Write a C program to input any number from user and find lowest order set bit of given number using bitwise operator. How to find first set bit in a given number using bitwise operator in C programming. Logic to get first set bit of a number using C program.

Example

Input

Input any number: 22

Output

First set bit: 1

Read more

C program to get highest order set bit of a number

Write a C program to input any number from user and find highest order set bit of given number using bitwise operator. How to find the highest order of the set bit of a given number using bitwise operator in C programming. Logic to get highest order set bit of a number in C programming.

Example

Input

Input any number: 22

Output

Highest order set bit in 22 is 4.

Read more

C program to flip all bits of a binary number

Write a C program to input a number from user and flip all bits of the given number (in binary representation) using bitwise operator. How to flip all bits of a binary number using bitwise operator in C programming.

Example

Input

Input any number: 22

Output

Number after bits are flipped: -23 (in decimal)

Read more

C program to toggle or invert nth bit of a number

Write a C program to input any number from user and toggle or invert or flip nth bit of the given number using bitwise operator. How to toggle nth bit of a given number using bitwise operator in C programming. C program set nth bit of a given number if it is unset otherwise unset if it is set.

Example

Input

Input number: 22
Input nth bit to toggle: 1

Output

After toggling nth bit: 20 (in decimal)

Read more

C program to clear nth bit of a number

Write a C program to input any number from user and clear the nth bit of the given number using bitwise operator. How to clear nth bit of a given number using bitwise operator in C programming. How to unset (0) the value of nth bit of a given number in C.

Example

Input

Input number: 13
Input nth bit to clear: 0

Output

Number after clearing nth bit: 12 (in decimal)

Read more