Determine if a number is a power of 2 at O(1).

Answer Posted / srinu naik

if((~n+1)& n ==n) printf("\n Given number is power of 2");
else printf("\Not the POwer of 2");

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Wt are the Buses in C Language

2753


What is header file in c?

604


Why is event driven programming or procedural programming, better within specific scenario?

1955


What is array within structure?

587


Differentiate between declaring a variable and defining a variable?

608






what are bit fields? What is the use of bit fields in a structure declaration?

1499


What is the purpose of type declarations?

681


Explain built-in function?

593


What do you mean by a sequential access file?

629


How can I recover the file name given an open stream?

556


What is structure padding in c?

628


what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;

2008


How many types of functions are there in c?

585


What is union and structure?

574


What is else if ladder?

610