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
Is there any possibility to create customized header file with c programming language?
What does void main () mean?
What are high level languages like C and FORTRAN also known as?
Write a program to show the change in position of a cursor using c
What does a function declared as pascal do differently?
How can I check whether a file exists? I want to warn the user if a requested input file is missing.
What is a char in c?
develop algorithms to add polynomials (i) in one variable
Write a program to check armstrong number in c?
PLS U SENS ME INTERVIEW O. MY EMAIL ADD, SOFIYA.SINGH@GMAIL.COM
What is the use of a conditional inclusion statement in C?
Write a program to find factorial of a number using recursive function.
What is a #include preprocessor?
Explain about C function prototype?
Write a program in c to replace any vowel in a string with z?