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

In this problem you are to write a program that will cut some number of prime numbers from the list of prime numbers between 1 and N.Your program will read in a number N; determine the list of prime numbers between 1 and N; and print the C*2 prime numbers from the center of the list if there are an even number of prime numbers or (C*2)-1 prime numbers from the center of the list if there are an odd number of prime numbers in the list.

1633


Q.1 write aprogram to stack using linklist o insert 40 items? Q.2 write a program to implement circular queue with help of linklist?

1838


What is typedef?

1035


Why can arithmetic operations not be performed on void pointers?

838


What is the difference between the local variable and global variable in c?

758


What is spaghetti programming?

910


What is the function of volatile in c language?

900


Write a program to find factorial of a number using recursive function.

889


Once I have used freopen, how can I get the original stdout (or stdin) back?

859


find the sum of two matrices and WAP for it.

916


How can my program discover the complete pathname to the executable from which it was invoked?

879


What library is sizeof in c?

845


Why header files are used?

867


Difference between macros and inline functions? Can a function be forced as inline?

979


In c language can we compile a program without main() function?

870