Function to find the given number is a power of 2 or not?
Answer Posted / udhaya
Find if the given number is a power of 2.
//include math.h
void main()
{
int n,logval,powval;
printf("Enter a number to find whether it is s power of
2\n");
scanf("%d",&n);
logval=log(n)/log(2);
powval=pow(2,logval);
if(powval==n)
printf("The number is a power of 2");
else
printf("The number is not a power of 2");
getch();
}
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
how do you execute a c program in unix.
Explain can the sizeof operator be used to tell the size of an array passed to a function?
In which header file is the null macro defined?
Can you think of a logic behind the game minesweeper.
What is variable in c example?
Linked list is a Linear or non linear explain if linear how it working as a non linear data structures
What is switch in c?
What is time null in c?
provide an example of the Group by clause, when would you use this clause
Explain how do you determine whether to use a stream function or a low-level function?
What is the general form of #line preprocessor?
Hi how many types of software editions are there and their difference (like home editions, enterprise, standard etc) can u please help me
What are identifiers in c?
What is integer constants?
What is meant by operator precedence?