Function to find the given number is a power of 2 or not?

Answer Posted / sivaraj

Answer 2 Ms is correct and more efficient.

because if a number is power 2 it is in form

1000---->8
100----->4
10------>2 like form
subtract one from that and do with bitwise and it should be
zero.

ie 1000(8) & 0111(7)== 0

Is This Answer Correct ?    55 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is #define?

569


What are the 4 data types?

592


Why pointers are used in c?

578


Which is better between malloc and calloc?

664


Write a program to find the biggest number of three numbers in c?

584






Why do we use return in c?

560


Hai sir, I had planned to write the NIC scientific engineer exam , plz post the sample question......

1738


Explain the difference between ++u and u++?

633


What is the function of multilevel pointer in c?

665


What is meant by keywords in c?

610


How does normalization of huge pointer works?

619


can any one please explain, how can i access hard disk(physical address)? it is possible by the use of far,near or huge pointer? if yes then please explain......

1398


WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?

1853


given post order,in order construct the corresponding binary tree

2312


Is c call by value?

596