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
Is c is a procedural language?
How do you print an address?
Explain pointer. What are function pointers in C?
If I have a char * variable pointing to the name of a function ..
What are the uses of a pointer?
How can I manipulate individual bits?
I need a sort of an approximate strcmp routine?
Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?
why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???
a direct address that identifies a location by means of its displacement from a base address or segment a) absolute address b) relative address c) relative mode d) absolute mode
What is structure padding in c?
What is pragma in c?
What is calloc()?
How can you avoid including a header more than once?
What are the benefits of c language?