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

Is r written in c?

907


How can I get random integers in a certain range?

803


What Is The Difference Between Null And Void Pointer?

869


What is the difference between text and binary modes?

884


Explain what are global variables and explain how do you declare them?

847


how is the examination pattern?

1796


Write the program with at least two functions to solve the following problem. The members of the board of a small university are considering voting for a pay increase for their 10 faculty members. They are considering a pay increase of 8%. Write a program that will prompt for and accept the current salary for each of the faculty members, then calculate and display their individual pay increases. At the end of the program, print the total faculty payroll before and after the pay increase, and the total pay increase involved.

2886


Is there any possibility to create customized header file with c programming language?

838


What is the difference between exit() and _exit() function in c?

845


write a program to reverse a every alternetive words in a string in a place. EX: Input is "this is the line of text" Output should be "shit is eht line fo text" Please any one tell me code for that.

1817


What is break in c?

807


about c language

1801


List out few of the applications that make use of Multilinked Structures?

1763


Why cant I open a file by its explicit path?

818


simple program of graphics and their output display

1713