Function to find the given number is a power of 2 or not?
Answer Posted / sahil
int ispwrof2(int num)
{
int temp = 0;
if(num <= 0)
return 0;
else if(num > 0)
{
while(num%2 == 0)
{
temp = num/2;
num = temp;
}
}
if(num == 1)
return 1;
else
return 0;
}
| Is This Answer Correct ? | 18 Yes | 7 No |
Post New Answer View All Answers
Which is better between malloc and calloc?
What do you know about the use of bit field?
Draw a flowchart to produce a printed list of all the students over the age of 20 in a class .The input records contains the name and age of students. Assume a sentinel value of 99 for the age field of the trailer record
Is c object oriented?
Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]
explain what are pointers?
What is scope rule of function in c?
What is the maximum length of an identifier?
Describe the order of precedence with regards to operators in C.
a) Identify the following declarations. Ex. int i (integer variable) float a[l0](array of 10 real nos) int (*f())() void *f int (*f()) [] void *f int f[] [] [] char *(*f) () int (*f[]) [] float(*f) [] [] float **f int ******f
Explain about block scope in c?
What is a constant and types of constants in c?
What is c programing language?
Is main a keyword in c?
int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above