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...

Given an unsigned integer, find if the number is power of 2?

Answer Posted / sagar shah

#include<stdio.h>
main()
{
int i,n,r=2
clrscr();
scanf("%d",&n);
for(i=1;i<=n;i=r*i)
{
if(i==n)
{
r=0;
break;
}
}
if (r==0)
{
printf("power of two:");
}
else
{
printf("not power of two:");
}
getch();
}

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between mpi and openmp?

1265


What does node * mean?

1177


In which language linux is written?

1212


How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?

1015


Is that possible to add pointers to each other?

1348


Is file a keyword in c?

921


What are conditional operators in C?

1082


What does %c mean in c?

1072


what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?

2360


Explain the difference between ++u and u++?

1114


What is a const pointer in c?

1113


What is a pragma?

1111


Why does the call char scanf work?

1183


Is c programming hard?

1004


What is equivalent to ++i+++j?

1075