Given an unsigned integer, find if the number is power of 2?
Answer Posted / coder
#include<stdio.h>
void powerOfTwo(int number)
{
if(!(number & number-1) && number)
printf("\nthe number is a power of 2\n");
else printf("\nThe number is not a power of 2\n");
}
int main()
{
powerOfTwo(32); //power of 2
powerOfTwo(22); //not a power of 2
return 0;
}
| Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
Suppose we have a table name EMP as below. We want to perform a operation in which, I want to change name ‘SMITH’ from as ‘SMITH JAIN’. Also I want to change the name of the column from ENAME to E_NAME. EMPNO ENAME JOB MGR HIREDATE SAL 7369 SMITH Coder 7902 17-DEC-80 800 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 7521 WARD SALESMAN 7698 22-FEB-81 1250
Write a program to check palindrome number in c programming?
Explain the process of converting a Tree into a Binary Tree.
How can I make it pause before closing the program output window?
int main() { Int n=20,i; For(i=0;i<=n;i--) { Printf(“-“); Return 0;
Write a program to generate a pulse width frequency of your choise,which can be variable by using the digital port of your processor
what is the height of tree if leaf node is at level 3. please explain
What is new line escape sequence?
Is there a way to switch on strings?
What are the disadvantages of a shell structure?
difference between object file and executable file
Explain can you assign a different address to an array tag?
What is the need of structure in c?
Is file a keyword in c?
What is return type in c?