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 / barun
int x =0x1;
static count;
while(no ! =0)
{
if((no >>1 & x) ==1)
count+=1;
}
printf("%d",count);
Is This Answer Correct ? | 7 Yes | 2 No |
Post New Answer View All Answers
Tell us two differences between new () and malloc ()?
Explain what are compound statements?
Write a C program linear.c that creates a sequence of
processes with a given length. By
sequence it is meant that each created process has exactly
one child.
Let's look at some example outputs for the program.
Here the entire process sequence consists of process 18181:
Sara@dell:~/OSSS$ ./linear 1
Creating process sequence of length 1.
18181 begins the sequence.
An example for a sequence of length three:
Sara@dell:~/OSSS$ ./linear 3
Creating process sequence of length 3.
18233 begins the sequence.
18234 is child of 18233
18235 is child of 18234
........ this is coad .... BUt i could not compleate it .....:(
#include
How can I dynamically allocate arrays?
Why functions are used in c?
What are multibyte characters?
What is clrscr in c?
Do you know what are bitwise shift operators in c programming?
Explain how can a program be made to print the line number where an error occurs?
What is function pointer c?
What will be your course of action for a push operation?
Explain data types & how many data types supported by c?
What is the size of enum in c?
Explain how can I manipulate strings of multibyte characters?
Why static is used in c?