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 const keyword in c?

751


What is a function simple definition?

620


Write a program to print fibonacci series using recursion?

587


explain what are pointers?

619


Explain what is the general form of a c program?

625






write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list

2239


What is the size of empty structure in c?

595


How are strings stored in c?

596


What is the use of linkage in c language?

617


Can you subtract pointers from each other? Why would you?

558


List the difference between a 'copy constructor' and a 'assignment operator' in C?

639


What are the advantages and disadvantages of pointers?

579


What is I ++ in c programming?

629


What are the differences between Structures and Arrays?

612


what do you mean by enumeration constant?

599