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

What are dangling pointers in c?

1238


please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com

1777


What is data structure in c programming?

1083


What is the difference between %d and %i?

1100


What is a scope resolution operator in c?

1279


Explain what is the difference between #include and #include 'file' ?

1029


Why main is not a keyword in c?

1260


What is the usage of the pointer in c?

1141


What is selection sort in c?

1104


Explain what is the benefit of using enum to declare a constant?

1096


What does printf does?

1254


Tell me the use of bit field in c language?

1071


What are the differences between new and malloc in C?

1151


program to convert a integer to string in c language'

2458


Where is volatile variable stored?

1091