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

Why doesnt this code work?

1125


using for loop sum 2 number of any 4 digit number in c language

2419


Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)

1209


Explain modulus operator.

1090


Explain that why C is procedural?

1194


Explain how can I manipulate strings of multibyte characters?

1258


a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion

2845


What is the difference between array and pointer in c?

1232


Who is the main contributor in designing the c language after dennis ritchie?

1054


What is difference between %d and %i in c?

1310


What is the difference between far and near in c?

1121


What are the types of data structures in c?

1213


Where are c variables stored in memory?

1137


Can variables be declared anywhere in c?

1150


What is the difference between if else and switchstatement

2007