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

#include <stdio.h> #define a 10 main() { #define a 50 printf("%d",a); }

2 Answers  


How do I write a program to print proper subset of given string . Eg :input: abc output:{},{a},{b},{c},{a,b},{a,c},{b,c}, {a,b,c}.I desperately need this program please mail me to saravana6m@gmail.com

11 Answers   Deshaw, Infosys,


main() { char *p = “ayqm”; char c; c = ++*p++; printf(“%c”,c); }

1 Answers  


struct Foo { char *pName; }; main() { struct Foo *obj = malloc(sizeof(struct Foo)); clrscr(); strcpy(obj->pName,"Your Name"); printf("%s", obj->pName); } a. Your Name b. compile error c. Name d. Runtime error

3 Answers   HCL,


#include<stdio.h> main() { int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} }; int *p,*q; p=&a[2][2][2]; *q=***a; printf("%d..%d",*p,*q); }

1 Answers  






main() { printf("%d, %d", sizeof('c'), sizeof(100)); } a. 2, 2 b. 2, 100 c. 4, 100 d. 4, 4

18 Answers   HCL, IBM, Infosys, LG Soft, Satyam,


main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }

9 Answers   CSC, GoDB Tech, IBM,


String reverse with time complexity of n/2 with out using temporary variable.

10 Answers   NetApp, Symantec,


main() { int *j; { int i=10; j=&i; } printf("%d",*j); }

9 Answers   HCL, Wipro,


1 o 1 1 0 1 0 1 0 1 1 0 1 0 1 how to design this function format in c-language ?

2 Answers  


Write a single line c expression to delete a,b,c from aabbcc

2 Answers   Microsoft,


main() { struct date; struct student { char name[30]; struct date dob; }stud; struct date { int day,month,year; }; scanf("%s%d%d%d", stud.rollno, &student.dob.day, &student.dob.month, &student.dob.year); }

1 Answers  


Categories