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

What is pointer and structure in c?

1073


What is string in c language?

1075


What does 1f stand for?

1089


Explain how do you sort filenames in a directory?

983


What Is The Difference Between Null And Void Pointer?

1156


write a programe to accept any two number and check the following condition using goto state ment.if a>b,print a & find whether it is even or odd and then print.and a

1885


a) Identify the following declarations. Ex. int i (integer variable) float a[l0](array of 10 real nos) int (*f())() void *f int (*f()) [] void *f int f[] [] [] char *(*f) () int (*f[]) [] float(*f) [] [] float **f int ******f

2079


What is the heap in c?

1030


On most computers additional memory that is accessed through an adapter of feature card along with a device driver program. a) user memory b) conventional memory c) expandedmemory d) area

1070


Write a program to show the change in position of a cursor using c

997


What is I ++ in c programming?

1059


What is c language & why it is used?

1031


can any one provide me the notes of data structure for ignou cs-62 paper

2118


What does c mean in standard form?

1101


Which programming language is best for getting job 2020?

985