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

Find if the given number is a power of 2.
//include math.h
void main()
{
int n,logval,powval;
printf("Enter a number to find whether it is s power of
2\n");
scanf("%d",&n);
logval=log(n)/log(2);
powval=pow(2,logval);
if(powval==n)
printf("The number is a power of 2");
else
printf("The number is not a power of 2");
getch();
}

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how do you execute a c program in unix.

1074


Explain can the sizeof operator be used to tell the size of an array passed to a function?

1015


In which header file is the null macro defined?

1302


Can you think of a logic behind the game minesweeper.

2415


What is variable in c example?

993


Linked list is a Linear or non linear explain if linear how it working as a non linear data structures

2120


What is switch in c?

1047


What is time null in c?

1005


provide an example of the Group by clause, when would you use this clause

2127


Explain how do you determine whether to use a stream function or a low-level function?

1025


What is the general form of #line preprocessor?

948


Hi how many types of software editions are there and their difference (like home editions, enterprise, standard etc) can u please help me

1898


What are identifiers in c?

1144


What is integer constants?

1015


What is meant by operator precedence?

1096