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

How many main () function we can have in a project?

1158


how can use subset in c program and give more example

2049


What are bitwise shift operators in c programming?

1137


What is the purpose of & in scanf?

1122


Explain the properties of union. What is the size of a union variable

1248


What are 3 types of structures?

1106


What does void main () mean?

1300


What are pointers really good for, anyway?

1118


what is different between auto and local static? why should we use local static?

1171


Can a function argument have default value?

1210


Describe newline escape sequence with a sample program?

1172


What is methods in c?

1143


What are the 5 types of inheritance in c ++?

1073


What is the difference between ++a and a++?

1274


What are types of structure?

1173