Function to find the given number is a power of 2 or not?
Answer Posted / sujan.t
/* 100% correct answer */
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 is NOT A power of two");
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
List some applications of c programming language?
write a program that types this pattern: 12345678987654321 12345678 87654321 1234567 7654321 123456 654321 12345 54321 1234 4321 123 321 12 21 1 1
Explain what is a static function?
Why is extern used in c?
What is bin sh c?
why programs in c are running with out #include
Can you apply link and association interchangeably?
how can f be used for both float and double arguments in printf? Are not they different types?
How many levels of pointers have?
What is pointer to pointer in c with example?
What is data structure in c language?
What is c programing language?
Take an MxN matrice from user and then sum upper diagonal in a variable and lower diagonal in a separate variables. Print the result
What is time null in c?
How many types of errors are there in c language? Explain