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
What do you understand by friend-functions? How are they used?
Explain about the functions strcat() and strcmp()?
c program for searching a student details among 10 student details
hw can we delete an internal node of binary search tree the internal node has child node..plz write progarm
Are negative numbers true in c?
we called a function and passed something do it we have always passed the "values" of variables to the called function. such functions calles are called a) calls by reference b) calls by value c) calls by zero d) none of the above
Can true be a variable name in c?
What is the use of function in c?
Does c have enums?
What is function prototype?
Where is c used?
Explain how do you use a pointer to a function?
what is the syallabus of computer science students in group- 1?
How many types of errors are there in c language? Explain
How do you search data in a data file using random access method?