Bitwise Operations: Working on individual bits

Write code to perform the basic operations on individual bits of a number (rather than the entire number): setBit – Set a particular bit. resetBit […]

Find numbers with more than k-bits in their binary representations

Given an array of unsigned integers, print all the numbers that have more than k bits set in their binary representation. For example, if k […]

Find minimum of 3 numbers without using comparator operator

How will you find minimum of three integers without using any comparison operator ?

Maximum XOR value of two elements

Given an array of numbers find the maximum XOR value of two numbers in the array. Input Array = {12, 15, 5, 1, 7, 9, […]

Compute x^n (x to the power n)

Write a C function to compute xn which uses minimum number of multiplications. unsigned int power(double x, unsigned int n)

Next greater power of 2

Given an unsigned int n, find the integer greater than or equal to n which is a power of 2. For example: Input Output ----- […]

Add two integers without using arithmetic operator

Write a function that accepts two unsigned int and return sum of these two integers. The function should not use any arithmetic operator (mayuse bitwise […]

Find larger of 2 elements without branching

Given two unsigned integers, find the larger (or smaller) of the two without using branching (if-else or conditional operator).

Making both elements of an array zero

Given an Array of two elements one of which is 0, the other is either 0 or 1. You have to make both the elements […]

Check if number is a power of 2

How will you check if a number if a power of two or not? For example: 4, 8, 1024 etc are powers of two. But […]