Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Answer Posted / hassan noureddine

int isPowrOf2 (unsigned int number)
{
float x;

if (number <= 0) return (0);

x = log(number) / log(2);
return ( (int) ( ((int)x*log(2))/log(number)));
}

Is This Answer Correct ?    4 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

.find the output of the following program? char*myfunc(char*ptr) { ptr +=3; return (ptr); } int main() { char*x,*y; x="HELLO"; y=myfunc(x); printf("y = %s ",y); return 0; }

2589


Can static variables be declared in a header file?

1062


What is queue in c?

1109


What is string in c language?

1161


a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above

1233


Why doesnt this code work?

1069


Explain what is a stream?

1093


When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?

1273


Why clrscr is used in c?

1018


What oops means?

1004


What is the difference between union and structure in c?

1183


Why is c called a mid-level programming language?

1209


How can I write a function that takes a format string and a variable number of arguments?

1060


What is nested structure?

1048


How do I use strcmp?

1082