Find if a number is power of two or not?
Answer / om
int f(int num)
{
if(( num>0) && (!(num & (num-1))) )
return 1;
else
return 0;
}
// f(16)...... 16 & 15 = 10000 & 01111 =00000
f(4) ...... 4 & 3 =0100 & 0111 =0000
f(11).......11 & 10 = 1011 & 1010 = 1010 so not...
f(12).......12 & 11 = 1100 & 1011 = 1000 so not...
Is This Answer Correct ? | 6 Yes | 0 No |
Please send me WIPRO technical question to my mail ID.. its nisha_g28@yahoo.com please its urgent
What is c method?
int array[]={1,2,3,4,5,6,7,8}; #define SIZE (sizeof(array)/sizeof(int)) main() { if(-1<=SIZE) printf("1"); else printf("2"); }
Can we use any name in place of argv and argc as command line arguments?
What is the scope of static variable in c?
How does sizeof know array size?
In c programming language, how many parameters can be passed to a function ?
Why is #define used?
what is pointer?
13 Answers HCL, TCS,
What is selection sort in c?
why Language C is plateform dependent
in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none