Given an unsigned integer, find if the number is power of 2?
Answer Posted / asis bera
main()
{
unsigned int n;
printf("enter the number:\n");
scanf("%u",&n);
if(i&(i-1))
printf(" not power of two\n");
else
printf("power of two...\n");
}
Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
What is the significance of scope resolution operator?
What is the purpose of sprintf?
How can you determine the size of an allocated portion of memory?
Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions?
How do you define a string?
Why can't I perform arithmetic on a void* pointer?
Do you know the purpose of 'register' keyword?
Explain what does the characters 'r' and 'w' mean when writing programs that will make use of files?
What is difference between structure and union in c?
How reliable are floating-point comparisons?
What is the explanation for modular programming?
What is a file descriptor in c?
Write a simple code fragment that will check if a number is positive or negative.
What is getche() function?
Which is more efficient, a switch statement or an if else chain?