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


Please Help Members By Posting Answers For Below Questions

Should I learn c before c++?

605


Define Spanning-Tree Protocol (STP)

642


A program is required to print your biographic information including: Names, gender, student Number, Cell Number, line of study and your residential address.

1250


What are the types of unary operators?

659


write a program which the o/p should b in such a way that s triangle if I/p is 3,a Square/rectangle if I/P=4,a pentagon if I/P=5 and so on...forget about the I/P which is less than 3

1644






Why & is used in scanf in c?

623


Why is c called c not d or e?

610


What is the difference between c and python?

584


Difference between exit() and _exit() function?

655


Write a C program to accept a matrix of any size. Find the frequency count of each element in the matrix and positions in which they appear in the matrix

1515


write a program to find the given number is prime or not

3842


What is the size of enum in bytes?

586


Why header files are used?

643


Explain what is the general form of a c program?

622


On most computers additional memory that is accessed through an adapter of feature card along with a device driver program. a) user memory b) conventional memory c) expandedmemory d) area

664