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

hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?

1656


How many types of operators are there in c?

613


What is c++ used for today?

664


Explain heap and queue.

580


What is the difference between array and pointer?

567






Tell us two differences between new () and malloc ()?

612


write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.

1981


find the output? void r(int a[],int c, int n) { if(c>n) { a[c]=a[c]+c; r(a,++c,n); r(a,++c,n); } } int main() { int i,a[5]={0}; r(a,0,5); for(i=0;i<5;i++) printf("\n %d",a[i]); getch(); }

1857


What is the purpose of clrscr () printf () and getch ()?

591


How to write a multi-statement macro?

621


List at least 10 sorting methods indicating their average case complexity, worst case complexity and best case complexity.

2303


What is wrong with this declaration?

611


What is a rvalue?

747


write a program to display all prime numbers

1454


Why is c called c?

622