write a program to find out number of on bits in a number?
Answer Posted / vaishu and hema
main()
{
int n,count=0,rem;
scanf("%d",&n);
while(n>0)
{
rem=n%2;
if(rem==1)
count++;
n=n/2;
}
printf("The number of on bits in the number is %d",count);
}
| Is This Answer Correct ? | 7 Yes | 3 No |
Post New Answer View All Answers
What is the difference between char array and char pointer?
#include main() { char s[] = "Bouquets and Brickbats"; printf(" %c, ",*(&s[2])); printf("%s, ",s+5); printf(" %s",s); printf(" %c",*(s+2)); }
What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?
Implement bit Array in C.
What does %p mean?
What is string length in c?
Who developed c language and when?
What are global variables and explain how do you declare them?
What is the difference between local variable and global variable in c?
my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?
Write a program to check palindrome number in c programming?
Write a function expand(s1,s2) that expands shorthand notations like a-z in the string s1 into the equivalent complete list abc...xyz in s2 . Allow for letters of either case and digits, and be prepared to handle cases like a-b-c and a-z0-9 and -a-z. z-a:zyx......ba -1-6-:-123456- 1-9-1:123456789987654321 a-R-L:a-R...L a-b-c:abbc
Are the outer parentheses in return statements really optional?
A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers
What are the main characteristics of c language describe the structure of ac program?