write a program to find out number of on bits in a number?
Answer Posted / naveen
//plz let me know whether it is correct or not...bcoz am just beginner
#include<stdio.h>
void main()
{
int j=0,i=0xFFFFE,temp=1;
int count=0;
while(j<=(sizeof(int)*8-1))
{
if(i&temp)
count++;
temp=temp<<1;
j++;
}
printf("%d",count);
}
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
Explain which function in c can be used to append a string to another string?
What is the purpose of type declarations?
What is the difference between strcpy() and memcpy() function in c programming?
What is the use of ?: Operator?
What is the difference between break and continue?
What are the different file extensions involved when programming in C?
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
a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list
What is void main () in c?
The performance of an operation in several steps with each step using the output of the preceding step a) recursion b) search c) call by value d) call by reference
What are the types of functions in c?
write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list
Explain what is the purpose of "extern" keyword in a function declaration?
How can I call fortran?
What are the rules for identifiers in c?