Finding a number which was log of base 2



Finding a number which was log of base 2..

Answer / jaganathan gnanavelu

log of base 2 means given variable is power of 2. So

void main(){
int x;
if(x&(x-1){
printf("Given Number is not log base 2\n");
}

}

Is This Answer Correct ?    5 Yes 2 No

Post New Answer

More C Code Interview Questions

Ramesh’s basic salary is input through the keyboard. His dearness allowance is 40% of basic salary, and house rent allowance is 20% of basic salary. Write a program to calculate his gross salary.

1 Answers  


Write a complete program that consists of a function that can receive two numbers from a user (M and N) as a parameter. Then print all the numbers between the two numbers including the number itself. If the value of M is smaller than N, print the numbers in ascending flow. If the value of M is bigger than N, print the numbers in descending flow. may i know how the coding look like?

2 Answers  


main() { int i=_l_abc(10); printf("%d\n",--i); } int _l_abc(int i) { return(i++); }

2 Answers  


Write a Program in 'C' To Insert a Unique Number Only. (Hint: Just Like a Primary Key Numbers In Database.) Please Some One Suggest Me a Better Solution for This question ??

0 Answers   Home,


what will be the output of this program? void main() { int a[]={5,10,15}; int i=0,num; num=a[++i] + ++i +(++i); printf("%d",num); }

3 Answers   Wipro,






Code for 1>"ascii to string" 2>"string to ascii"

1 Answers   Aricent, Global Logic,


‎#define good bad main() { int good=1; int bad=0; printf ("good is:%d",good); }

2 Answers  


1. const char *a; 2. char* const a; 3. char const *a; -Differentiate the above declarations.

3 Answers  


main() { char *p="GOOD"; char a[ ]="GOOD"; printf("\n sizeof(p) = %d, sizeof(*p) = %d, strlen(p) = %d", sizeof(p), sizeof(*p), strlen(p)); printf("\n sizeof(a) = %d, strlen(a) = %d", sizeof(a), strlen(a)); }

1 Answers  


print a semicolon using Cprogram without using a semicolon any where in the C code in ur program!!

35 Answers   Tata Elxsi, TCS, VI eTrans,


can u give me the c codings for converting a string into the hexa decimal form......

1 Answers  


what will be the position of the file marker? a: fseek(ptr,0,SEEK_SET); b: fseek(ptr,0,SEEK_CUR);

2 Answers  


Categories