Give a method to count the number of ones in a 32 bit number?
Answer Posted / vignesh1988i
#include<stdio.h>
#include<conio.h>
void main()
{
unsigned i;
int j=0,count=0;;
printf("Enter the number :");
scanf("%ld",&i);
while(j<=31)
{
if(!(((i>>j)&1)^1))
count++;
j++;
}
printf("\nnumber of 1's in ur number is : %d",count);
getch();
}
thank u
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is function pointer c?
explain what is an endless loop?
What are the advantages of the functions?
Write a Program to accept different goods with the number, price and date of purchase and display them
Is anything faster than c?
Between macros and functions,which is better to use and why?
I need testPalindrome and removeSpace
#include
What does %2f mean in c?
Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?
What are categories used for in c?
any function have arguments one or more OR not . it is compulsary a) any function compulsary have one or more arguments b) any function did not have arguments. It is not compulsary c) it is optional it is not compulsary d) none of the above
What are 3 types of structures?
On most computers additional memory that is accessed through an adapter of feature card along with a device driver program. a) user memory b) conventional memory c) expandedmemory d) area
please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com
what is stack , heap ,code segment,and data segment