Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...

Find if a number is power of two or not?

Find if a number is power of two or not?..

int f(int num)
{

if(( num>0) && (!(num & (num-1))) )
return 1;
else
return 0;
}
// f(16)...... 16 & 15 = 10000 & 01111 =00000
f(4) ...... 4 & 3 =0100 & 0111 =0000

f(11).......11 & 10 = 1011 & 1010 = 1010 so not...
f(12).......12 & 11 = 1100 & 1011 = 1000 so not...

 Is This Answer Correct ? 6 Yes 0 No

More C Interview Questions

What is the scope of local variable in c?

what is op? for(c=0;c=1000;c++) printf("%c",c);

In a byte, what is the maximum decimal number that you can accommodate?

What is the difference between printf and scanf )?

An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above

define function

What is null character in c?

What is the role of && operator in a program code?

what will the following program do? void main() { int i; char a[]="String"; char *p="New Sring"; char *Temp; Temp=a; a=malloc(strlen(p) + 1); strcpy(a,p); //Line no:9// p = malloc(strlen(Temp) + 1); strcpy(p,Temp); printf("(%s, %s)",a,p); free(p); free(a); } //Line no 15// a) Swap contents of p & a and print:(New string, string) b) Generate compilation error in line number 8 c) Generate compilation error in line number 5 d) Generate compilation error in line number 7 e) Generate compilation error in line number 1

Explain the term printf() and scanf() used in c language?

biggest of two no's with out using if condition statement

#include<stdio.h> #include<conio.h> void main() { float a; clrscr(); a=0.5; if(a==0.5) printf("yes"); else printf("no"); getch(); }

Categories