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
printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions
Is c programming hard?
Explain about C function prototype?
What is non linear data structure in c?
What is the stack in c?
What are the application of void data type in c?
find the sum of two matrices and WAP for it.
pgm to find number of words starting with capital letters in a file(additional memory usage not allowed)(if a word starting with capital also next letter in word is capital cann't be counted twice)
any restrictions have on the number of 'return' statements that may be present in a function. a) no restriction b) only 2 return statements c) only 1 return statements d) none of the above
Is fortran still used today?
Is there a way to jump out of a function or functions?
What is the use of sizeof () in c?
Can true be a variable name in c?
How can I read in an object file and jump to locations in it?
What are enumerated types?