venkat


{ City } bangalore
< Country > india
* Profession * software engineer
User No # 8178
Total Questions Posted # 0
Total Answers Posted # 3

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 42
Users Marked my Answers as Wrong # 8
Questions / { venkat }
Questions Answers Category Views Company eMail




Answers / { venkat }

Question { 13575 }

What is the most efficient way to count the number of bits
which are set in a value?


Answer

main()
{
int n,count=0;
printf("enter a number");
scanf("%d",&n);//enterd no.is 5
while(n>0)
{
count++;
n=n&n-1;//binary of n is 101
// binary of n-1 is 100
//n&n-1 is (i.e 101
&100 =100 )

}
printf("%d",count);
getch();
} output is 2(i.e 2 ones in 101)

Is This Answer Correct ?    31 Yes 6 No

Question { Microsoft, 26689 }

write a program to find out number of on bits in a number?


Answer

main()
{
int n,counter;
printf("enter a number");
scanf("%d",&n);// let n=5
while(n>0)
{
counter++;
n=n&(n-1);
}
printf("%d",counter);
getch();
}

Is This Answer Correct ?    11 Yes 2 No


Question { Adobe, 7389 }

what is the use of pointers


Answer

by using pointers
1)we can pass the function arguments to another function
2)it holds the address of another function
3)it acts as a call back function

Is This Answer Correct ?    0 Yes 0 No