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

What is s in c?

996


Explain how can I prevent another program from modifying part of a file that I am modifying?

1036


i have to apply for the rbi for the post of officers. i need to know abt the entrance questions whether it may be aps or techinical....

1916


Is it better to bitshift a value than to multiply by 2?

1049


write a C program:There is a mobile keypad with numbers 0-9 and alphabets on it. Take input 0f 7 keys and then form a word from the alphabets present on the keys.

15927


exit () is used to a) exit () terminates the execution of the program itself b) exit () terminates the execution of the loop c) exit () terminates the execution of the block d) none of the above

1069


Is malloc memset faster than calloc?

1015


Write a program to print “hello world” without using semicolon?

1076


the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?

945


What is the difference between break and continue?

1396


What is the difference between new and malloc functions?

1051


program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)

2044


Differentiate between #include<...> and #include '...'

1003


What are variables c?

997


When should a type cast be used?

964