MORE ON BITWISE

2 views
Skip to first unread message

swadhin jaiswal

unread,
Oct 25, 2011, 5:39:38 AM10/25/11
to bbswork...@googlegroups.com
hello friends..
          hope u are enjoying diwali..we have found our last class(bitwise and switch-case) was very much intractive..i am going to attach some of good questions on bitwise which is frequently asked in technical interview.
.


1) Write an efficient program to count number of 1s in binary representation of an integer.

2)Wap which returns greater and lesser than given no which is power of 2..ex:for input 47,lesser sud be 32 and greater sud be 64..

3)Mutiply with (5,7,3,3.5) to given no..using only bitwise..

4)Given an array of positive integers. All numbers occur even number of times except one number which occurs odd number of times. Find the number in O(n) time & constant space.

5)Write a C function that unsets the rightmost set bit of an integer..

6)ADD 1 to a given no. without using arithmatic operator..




we have more stuffs on bitwise,which we'll discuss after diwali...

happy and safe diwali to all of u..
510.gif

CHANDRA BHANU SHUKLA

unread,
Oct 25, 2011, 9:49:30 AM10/25/11
to bbswork...@googlegroups.com
happy diwali to u also swadhin . tellme abot concept of mask using in bitwise operator.
510.gif

swadhin jaiswal

unread,
Nov 1, 2011, 3:51:14 AM11/1/11
to bbswork...@googlegroups.com

actually masking is used set or unset the bits of a number...we can use mask depending on the situation..
example...suppose we have a number n=27 or in binary n=11011 and we want to set bit 3rd from right..
   we'll do  n | 100 which will result 11111..
now if we want to unset bit 3rd...
n&11...1111011 which will result 11011..
there are many uses of masking in aplication of digital communications..

Reply all
Reply to author
Forward
0 new messages