Find if a number is power of two or not?
Answer / om
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 |
what is the difference between #include<stdio.h> and #include"stdio.h" ?
explain memory layout of a C program
Write a c program to print the sizes and ranges of different data types in c?
what is the disadvantage of using macros?
When should the volatile modifier be used?
How many types of sorting are there in c?
What is #line in c?
Why is C language being considered a middle level language?
What is a c token and types of c tokens?
what is c
write c program without semicolon
11 Answers MindTech, TCS, Wipro,
What does volatile do?