Find Index of least significant bit set in an Integer. ex.
int value is say 10001000 results should be 4.

Answer Posted / supri

I think the following code will help!!!!!!
#include<stdio.h>
main()
{
int a,count=0;
scnaf("%d",&a);
while(a)
{
if(a&1==1)
{
printf("%d",++count);
break;
}
a=a>>1;
++Count;
}
return;
}

Is This Answer Correct ?    7 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the meaning of 2d in c?

617


Is void a keyword in c?

584


i have to apply for the rbi for the post of officers. i need to know abt the entrance questions whether it may be aps or techinical....

1528


How can a program be made to print the line number where an error occurs?

656


Explain heap and queue.

591






What is nested structure?

580


What are Macros? What are its advantages and disadvantages?

651


int i=10; printf("%d %d %d", i, i=20, i);

1018


What does == mean in texting?

670


What is a char in c?

559


Why clrscr is used after variable declaration?

1045


Can we compile a program without main() function?

637


What does c mean?

594


What do you mean by keywords in c?

632


Explain how do you view the path?

662