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 / swathi sharma

#include<stdio.h>
int main()
{
int num,i=1;
printf("Enter the number:");
scanf("%d", &num);
do
{
i=i*2;
if(i==num)
{
printf("\n The no.is power of 2.");
break;
}
else if(i>num)
{
printf("\n The no. is not power of 2");
break;
}
}
while(i != num);
return 0;
}

Is This Answer Correct ?    8 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

The __________ attribute is used to announce variables based on definitions of columns in a table?

1205


Write a program to print factorial of given number without using recursion?

992


What is the return type of sizeof?

1063


Why string is used in c?

1007


What are the general description for loop statement and available loop types in c?

1125


What does do in c?

1041


What is the use of define in c?

1058


Write a program to print fibonacci series using recursion?

1062


How can I read data from data files with particular formats?

1048


Explain argument and its types.

1062


What is #include conio h?

996


Which built-in library function can be used to match a patter from the string?

1299


What is the use of static variable in c?

1091


What is the use of extern in c?

1092


What does & mean in scanf?

1105