# Category Archives: Bit Magic

Given an integer n, calculate the square of a number without using *, / and pow().  Examples :  Input: n = 5 Output: 25 Input:… Read More
A Bitwise And operator is represented as ‘&’ and a logical operator is represented as ‘&&’. The following are some basic differences between the two… Read More
In C, we can specify size (in bits) of structure and union members. The idea is to use memory efficiently when we know that the… Read More
Written Test: 1) 15 Aptitude Questions 2) 25 CS Fundamentals & Couple of output questions. 3) Coding Question: A thief trying to escape from a… Read More
Write a function which returns 1 that 2 is passed and return 2 when 1 is passed.Source: Adobe Interview Experience | Set 19 (For MTS)A… Read More
Round 1 : Written : Q1. Given a stream of around billion numbers in an array, which has approximately only 1000 unique numbers. Print the… Read More
Checking your coding capabilities and thinking level is their main motive. Hence the whole procedure I was involved in dealt only with coding questions. 😀… Read More
Given an integer ‘x’, write a C function that returns true if binary representation of x is palindrome else return false.For example a numbers with… Read More
A nibble is a four-bit aggregation, or half an octet. There are two nibbles in a byte. Given a byte, swap the two nibbles in it.… Read More
Given a number n and a value k, turn off the k’th bit in n. Please note that k = 1 means the rightmost bit.Examples:  … Read More
Given a number n, write a function that returns true if n is divisible by 9, else false. The most simple way to check for… Read More
In C, the following 6 operators are bitwise operators (work at bit-level)     The & (bitwise AND) in C or C++ takes two numbers as… Read More
Given two variables, x, and y, swap two variables without using a third variable.  Method 1 (Using Arithmetic Operators)  The idea is to get… Read More
Given two integers, write a function to multiply them without using multiplication operator.There are many other ways to multiply two numbers (For example, see this).… Read More
Travelling Salesman Problem (TSP): Given a set of cities and distance between every pair of cities, the problem is to find the shortest possible route… Read More