how do u find out the number of 1's in the binary
representation of a decimal number without converting it
into binary(i mean without dividing by 2 and finding out
the remainder)? three lines of c code s there it
seems...can anyone help
Answer Posted / srsabariselvan
int main()
{
int n,i=0;
scanf("%d",&n);
while(n!=0)
{
if(n&01)
i++;
n>>=1;
}
printf("%d",i);
}
| Is This Answer Correct ? | 3 Yes | 2 No |
Post New Answer View All Answers
One of the Institutes contains 5 student groups. Every group contains 4 students. Institute wants to store student group’s details in array. Group should contain group member’s details (name and registration number and age), project name, and mark of the group.
Can a local variable be volatile in c?
The number of measuring units from an arbitarary starting point in a record,area,or control block to some other point a) recording pointer b) offset c) branching d) none
What is break in c?
What is sizeof array?
What is the difference between fread buffer() and fwrite buffer()?
Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?
What is array in C
Can you apply link and association interchangeably?
What is static volatile in c?
void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }
What is structure in c explain with example?
Explain what is meant by 'bit masking'?
What is a shell structure examples?
Why & is used in scanf in c?