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 ftell?
Why c is called top down?
Write a program to display all the prime nos from 1 to 1000000, your code should not take time more than a minute to display all the nos.
How does #define work?
What's the best way of making my program efficient?
write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?
Why do we use main function?
What are the ways to a null pointer can use in c programming language?
A SIMPLE PROGRAM OF GRAPHICS AND THEIR OUTPUT I WANT SEE WAHAT OUTOUT OF GRAPHICS PROGRAM
Is c call by value?
Can you explain the four storage classes in C?
What is the difference between the expression “++a” and “a++”?
What are the types of data types and explain?
What is array of structure in c?
how to find anagram without using string functions using only loops in c programming