Function to find the given number is a power of 2 or not?

Answer Posted / abhinay

main()
{
int n,m;
do
{
m=n%2;
n=m;
}
while(n>1);
if(m==1)
{
Printf("Number is not a power of 2");
}
else
{
printf("Number is a power of 2");
}
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between union and structure in c?

581


How can a string be converted to a number?

521


What is the difference between declaring a variable by constant keyword and #define ing that variable?

2704


How can I ensure that integer arithmetic doesnt overflow?

612


What would the following code segment printint k = 8;docout << "k = " << k << " ";while k++ < 5; a) 13 b) 5 c) 8 d) pointers

683






what value is returned to operating system after program execution?

1608


Is there sort function in c?

581


Tell me about low level programming languages.

648


What are # preprocessor operator in c?

634


A c program to display count values from 0 to 100 and flash each digit for a secong.reset the counter after it reaches 100.use for loop,. pls guys hepl me.. :(

1744


Why is python slower than c?

609


What is const keyword in c?

753


FORMATTED INPUT/OUTPUT functions are a) scanf() and printf() b) gets() and puts() c) getchar() and putchar() d) all the above

627


What is nested structure?

578


What is table lookup in c?

633