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 / sujan

int n = 3;
boolean bool = true;
int reminder;
while (n >1)
{
reminder = n % 2;
if(reminder != 0)
{
bool = false;
break;
}
else
{
n = n / 2;
}
}
if (bool == true)
printf("The number is a power of two");
else
printf("The number "+ m + " is NOT A power of two");

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is c is a procedural language?

1031


How do you print an address?

1206


Explain pointer. What are function pointers in C?

1012


If I have a char * variable pointing to the name of a function ..

1110


What are the uses of a pointer?

1093


How can I manipulate individual bits?

982


I need a sort of an approximate strcmp routine?

984


Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?

1016


why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???

1911


a direct address that identifies a location by means of its displacement from a base address or segment a) absolute address b) relative address c) relative mode d) absolute mode

1049


What is structure padding in c?

1051


What is pragma in c?

1124


What is calloc()?

1023


How can you avoid including a header more than once?

927


What are the benefits of c language?

1105