Function to find the given number is a power of 2 or not?
Answer Posted / sujan
int n = 3;
boolean bool = true;
int reminder;
while (n >1)
{
reminder = n % 2;
if(reminder != 0)
{
bool = false;
break;
}
else
{
n = n / 2;
}
}
if (bool == true)
printf("The number is a power of two");
else
printf("The number "+ m + " is NOT A power of two");
Is This Answer Correct ? | 5 Yes | 1 No |
Post New Answer View All Answers
What is the purpose of realloc()?
How many header files are in c?
Is null always defined as 0(zero)?
Write the syntax and purpose of a switch statement in C.
What does the format %10.2 mean when included in a printf statement?
main() { printf("hello"); fork(); }
How can I get back to the interactive keyboard if stdin is redirected?
What does sizeof function do?
Explain what is the benefit of using const for declaring constants?
What is the difference between array and linked list in c?
What do you mean by scope of a variable in c?
Can a variable be both constant and volatile?
What is identifiers in c with examples?
Does c have enums?
Why is c faster?