Given an unsigned integer, find if the number is power of 2?
Answer Posted / sagar shah
#include<stdio.h>
main()
{
int i,n,r=2
clrscr();
scanf("%d",&n);
for(i=1;i<=n;i=r*i)
{
if(i==n)
{
r=0;
break;
}
}
if (r==0)
{
printf("power of two:");
}
else
{
printf("not power of two:");
}
getch();
}
Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
What is the g value paradox?
Differentiate abs() function from fabs() function.
What is const and volatile in c?
Explain what are compound statements?
Is stack a keyword in c?
What is the use of sizeof () in c?
What is the difference between procedural and declarative language?
What is strcmp in c?
Where are the auto variables stored?
What is keyword in c?
what value is returned to operating system after program execution?
hi any body pls give me company name interview conduct "c" language only
Do you have any idea how to compare array with pointer in c?
develop algorithms to add polynomials (i) in one variable
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.