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 |
What are file streams?
Why is event driven programming or procedural programming, better within specific scenario?
How can I read and write comma-delimited text?
Explain b+ tree?
What is the difference between formatted&unformatted i/o functions?
Explain how can I avoid the abort, retry, fail messages?
What are enumerated types?
What is output of the following program ? main() { i = 1; printf("%d %d %d\n",i,i++,i++); }
Write a program that takes a 5 digit number and calculates 2 power that number and prints it
5 Answers ABS, Accenture, HCL, Infosys, Infotech, SoftSolve, Software India, TCS, Vertex, Vimukti Technologies,
What would be an example of a structure analogous to structure c?
Explain what a Binary Search Tree is.
c program to subtract between two numbers without using '-' sign and subtract function.