Determine if a number is a power of 2 at O(1).

Answer Posted / hary

int Isnopowerof2(int n)
{
if (n & n-1)
return 0;
return 1;
}

Is This Answer Correct ?    15 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?

746


illustrate the use of address operator and dereferencing operator with the help of a program guys plzzz help for this question

1584


Can include files be nested?

629


Describe the steps to insert data into a singly linked list.

622


what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;

2008






Is c compiled or interpreted?

667


If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?

780


Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

604


What is string concatenation in c?

568


Is register a keyword in c?

638


Can variables be declared anywhere in c?

624


The number of measuring units from an arbitarary starting point in a record,area,or control block to some other point a) recording pointer b) offset c) branching d) none

713


"C" language developed by "Dennis Ritchie" at AT & T. his remarks are a) too general, too abstract b) could deal with only specific problems c) lost generality of BCPL and B restored d) no remarks

660


the factorial of non-negative integer n is written n! and is defined as follows: n!=n*(n-1)*(n-2)........1(for values of n greater than or equal to 1 and n!=1(for n=0) Perform the following 1.write a c program that reads a non-negative integer and computes and prints its factorial. 2. write a C program that estimates the value of the mathematical constant e by using the formula: e=1+1/!+1/2!+1/3!+.... 3. write a c program the computes the value ex by using the formula ex=1+x/1!+xsquare/2!+xcube/3!+....

22232


What is an identifier?

628