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 ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Are comments included during the compilation stage and placed in the EXE file as well?

898


what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;

2345


ATM machine and railway reservation class/object diagram

5039


Differentiate between the expression “++a” and “a++”?

1019


write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.

2566


Does c have function or method?

824


what is the function of pragma directive in c?

914


Explain how do you generate random numbers in c?

848


what are the advantages of a macro over a function?

917


Explain how do you use a pointer to a function?

880


Explain a file operation in C with an example.

920


What is difference between %d and %i in c?

944


Why is structure important for a child?

861


difference between object file and executable file

6375


How can you pass an array to a function by value?

867