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 the three constants used in c?
What does the message "automatic aggregate intialization is an ansi feature" mean?
What's wrong with "char *p; *p = malloc(10);"?
Is main is a keyword in c?
Can two or more operators such as and be combined in a single line of program code?
Linked list is a Linear or non linear explain if linear how it working as a non linear data structures
Find string palindrome 10marks
5 Answers Honeywell, Infosys, Riktam, Roland,
What are void pointers in c?
what is the different between if-else and switch statment (other than syntax)
26 Answers CTS, Oracle, Scorpos,
wat are the two methods for swapping two numbers without using temp variable??
WAP to accept basic salary of an employee? Calculate it HRA=25%,DA=30%,PF=30%&net salary display all contents?
6 Answers Finite Infotech, Lovely Professional University, Wipro,
Tell me what are bitwise shift operators?