Given an unsigned integer, find if the number is power of 2?

Answer Posted / veerendra jonnalagadda

main()
{
int i;
printf("Enter Number :");
scanf("%d",&i);
if(i&(i-1))
printf("Not atwo power");
else
printf("Two 's Power");
}

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by scope of a variable in c?

546


Explain what are linked list?

627


What are terms in math?

595


The file stdio.h, what does it contain?

668


What are volatile variables in c?

522






Write a program to reverse a linked list in c.

648


How many main () function we can have in a project?

615


How can I get back to the interactive keyboard if stdin is redirected?

671


How do I get a null pointer in my programs?

621


write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);

1849


Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]

634


Sir i need notes for structure,functions,pointers in c language can you help me please

1947


What is line in c preprocessor?

617


pierrot's divisor program using c or c++ code

1733


What is the process to create increment and decrement stamen in c?

589