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

C program to set nth bit of a number

Write a C program to input any number from user and set nth bit of the given number as 1. How to set nth bit of a given number using bitwise operator in C programming. Setting nth bit of a given number using bitwise operator.

Example

Input

Input number: 12
Input nth bit to set: 0

Output

Number after setting nth bit: 13 in decimal

Read more

C program to get nth bit of a number

Write a C program to input any number from user and check whether nth bit of the given number is set (1) or not (0). How to check whether nth bit of a given number is set or unset using bitwise operator in C programming. C program to get the status of nth bit of a number.

Example

Input

Input number: 12
Input nth bit number: 2

Output

2 bit of 12 is set (1)

Read more

C program to check even or odd using bitwise operator

Write a C program to input any number and check whether the given number is even or odd using bitwise operator. How to check whether a number is even or odd using bitwise operator in C programming. Logic to check even odd using bitwise operator in C programming.

Example

Input

Input number: 12

Output

12 is even

Read more

C program to check Most Significant Bit (MSB) of a number is set or not

Write a C program to input any number from user and check whether Most Significant Bit (MSB) of given number is set (1) or not (0). How to check whether Most Significant Bit of any given number is set or not using bitwise operator in C programming. C program to get the status of the most significant bit of a number.

Example

Input

Input number: -1

Output

Most Significant Bit (MSB) of -1 is set (1).

Read more

C program to check Least Significant Bit (LSB) of a number is set or not

Write a C program to input any number from user and check whether the Least Significant Bit (LSB) of the given number is set (1) or not (0). How to check whether the least significant bit of a number is set or unset using bitwise operator in C programming. C program to get the status of least significant bit of a number.

Example

Input

Input number: 11

Output

Least Significant Bit of 11 is set (1).

Read more