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 are dangling pointers in c?
please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com
What is data structure in c programming?
What is the difference between %d and %i?
What is a scope resolution operator in c?
Explain what is the difference between #include and #include 'file' ?
Why main is not a keyword in c?
What is the usage of the pointer in c?
What is selection sort in c?
Explain what is the benefit of using enum to declare a constant?
What does printf does?
Tell me the use of bit field in c language?
What are the differences between new and malloc in C?
program to convert a integer to string in c language'
Where is volatile variable stored?