write a program to find out number of on bits in a number?
Answer Posted / ram
#include<stdio.h>
void main()
{
int a,count=0;
printf("enter a");
scanf("%d",&a);
while(a>0)
{
if(a%2==1)
count++;
a=a>>1;
}
printf("no of on bits =%d ",count);
}
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
what is the role you expect in software industry?
What is #include called?
how to write optimum code to divide a 50 digit number with a 25 digit number??
In cryptography, you could often break the algorithm if you know what was the original (plain) text that was encoded into the current ciphertext. This is called the plain text attack. In this simple problem, we illustrate the plain text attack on a simple substitution cipher encryption, where you know each letter has been substituted with a different letter from the alphabet but you don’t know what that letter is. You are given the cipherText as the input string to the function getwordSets(). You know that a plain text "AMMUNITION" occurs somewhere in this cipher text. Now, you have to find out which sets of characters corresponds to the encrypted form of the "AMMUNITION". You can assume that the encryption follows simple substitution only. [Hint: You could use the pattern in the "AMMUNITION" like MM occurring twice together to identify this]
What are runtime error?
What are linked lists in c?
Explain union.
What does static variable mean in c?
Explain what is the difference between the expression '++a' and 'a++'?
Which control loop is recommended if you have to execute set of statements for fixed number of times?
What is a good way to implement complex numbers in c?
Explain two-dimensional array.
What is the difference between far and near ?
Explain what is wrong with this statement? Myname = ?robin?;
Write a program which returns the first non repetitive character in the string?