Function to find the given number is a power of 2 or not?
Answer Posted / swathi sharma
#include<stdio.h>
int main()
{
int num,i=1;
printf("Enter the number:");
scanf("%d", &num);
do
{
i=i*2;
if(i==num)
{
printf("\n The no.is power of 2.");
break;
}
else if(i>num)
{
printf("\n The no. is not power of 2");
break;
}
}
while(i != num);
return 0;
}
| Is This Answer Correct ? | 8 Yes | 3 No |
Post New Answer View All Answers
The __________ attribute is used to announce variables based on definitions of columns in a table?
Write a program to print factorial of given number without using recursion?
What is the return type of sizeof?
Why string is used in c?
What are the general description for loop statement and available loop types in c?
What does do in c?
What is the use of define in c?
Write a program to print fibonacci series using recursion?
How can I read data from data files with particular formats?
Explain argument and its types.
What is #include conio h?
Which built-in library function can be used to match a patter from the string?
What is the use of static variable in c?
What is the use of extern in c?
What does & mean in scanf?