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 / santhi perumal

#include<stdio.h>
#include<conio.h>

int main()
{
int i,count = 0,number;

printf("Enter the number\n");
scanf("%d",&number);

for(i=15;i>=0;i--)
{
if((1<<i) & number)
count++;
}

if(count == 1)
printf("\nThe Given Number is Power of 2\n");
else
printf("\nThe Given Number is Not Power of 2\n");

}

Is This Answer Correct ?    7 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between text and binary i/o?

1061


State the difference between realloc and free.

1097


What does c value mean?

1205


while initialization of array why we use a[][2] why not a[2][]...?

2368


how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?

1947


write a program to generate address labels using structures?

4585


How old is c programming language?

1018


Is null equal to 0 in sql?

1156


Is using exit() the same as using return?

1370


What is data structure in c and its types?

1072


Why pointers are used?

1082


What are preprocessor directives in c?

1107


Do pointers store the address of value or the actual value of a variable?

1083


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

1177


What is the difference between #include

and #include “header file”?

1039