Post your problems on programming asked in placement tests and interviews and they will be solved jointly
Last edited by Shirish on Fri Apr 14, 2006 3:56 pm; edited 1 time in total
/*********************************************************
Program to find whether a number is power of 2
like 2, 4, 8, 16, 32, , without using division operator
Author : Shirish Goyal
*********************************************************/
#include <iostream.h>
int main()
{
long int a;
cout<<"Input a number ? ";
cin>>a;
cout<<endl<<a<<(((a & (a-1))==0)?" is":" is not")<<" a power of 2";
return 0;
}
This is spamming. You have already been warned about multiple-posting too. Please do not post any more topics like this.
If you want to share your programming knowledge, please use the Tutorials forum, but only if you are making a specific point.
-close-