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

Calculate the weighted average of a list of n numbers using the formula xavg = f1x1+f2x2+ ….+ fnxn where the f’s are fractional weighting factors, i.e., 0<=fi<1, and f1+f2+….+fn = 1

3637


What is sorting in c plus plus?

556


What are the features of c languages?

614


Why is c called c not d or e?

600


Where does the name "C" come from, anyway?

631






What is define directive?

627


why do some people write if(0 == x) instead of if(x == 0)?

641


Are enumerations really portable?

585


What is a class c rental property?

594


What is the difference between array and pointer?

558


What is volatile keyword in c?

573


Is r written in c?

716


Explain what are run-time errors?

600


Tell us bitwise shift operators?

587


please help me..... please codes and flowchart plz turbo c lang po yan.....please asap response... 3. Make an astrology program. The user types in his or her birthday (month, day, and year as integer), and the program responds with the user’s zodiac sign, horoscope, and other information related to it. If the user’s birth year falls into a leap year, your program should display an appropriate message for it. NOTES: Conditional Statements: it should be with graphics

2850