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.t

/* 100% correct answer */

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 is NOT A power of two");

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

List some applications of c programming language?

956


write a program that types this pattern: 12345678987654321 12345678 87654321 1234567 7654321 123456 654321 12345 54321 1234 4321 123 321 12 21 1 1

3941


Explain what is a static function?

1111


Why is extern used in c?

1091


What is bin sh c?

1042


why programs in c are running with out #include? some warnings are display in terminal but we execute the program we get answer why? eg: main() { printf("hello world "); }

1765


Can you apply link and association interchangeably?

1125


how can f be used for both float and double arguments in printf? Are not they different types?

1070


How many levels of pointers have?

1050


What is pointer to pointer in c with example?

1074


What is data structure in c language?

1110


What is c programing language?

1085


Take an MxN matrice from user and then sum upper diagonal in a variable and lower diagonal in a separate variables. Print the result

1906


What is time null in c?

1072


How many types of errors are there in c language? Explain

986