ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
Give a method to count the number of ones in a 32 bit number?
 Question Submitted By :: A. Sujatha
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Give a method to count the number of ones in a 32 bit number?
Answer
# 1
#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
Vignesh1988i
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
WAP to accept rollno,course name & marks of a student & display grade if total marks is above 200?  2
a number is perfect if it is equal to the sum of its proper divisor.. 6 is perfect number coz its proper divisors are 1,2 and three.. and 1+2+3=6... a number is deficient if the sum of its proper divisor is less than the number.. sample: 8 is deficient, coz its proper divisors are 1,2 and 4, and 1+2+4=7. abundant number, if the sum of its proper divisor is greater than the number.. sample..12 is abundant coz 1+2+3+4+6=16 which is geater than 12. now write a program that prompts the user for a number, then determines whether the number is perfect,deficient and abundant..  1
main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf("%d %d\n",x,y); } what is the output? Ramco4
What is C language Terminator? TCS12
write a c program to accept a given integer value and print its value in words  3
any string of bits of length 'n' represents a unique non- negative integer between.............?  2
#define min((a),(b)) ((a)<(b))?(a):(b) main() { int i=0,a[20],*ptr; ptr=a; while(min(ptr++,&a[9])<&a[8]) i=i+1; printf("i=%d\n",i);}  3
Why the use of alloca() is discouraged? Oracle2
why i join syntel? Syntel12
how many keywords do C compile? Microsoft2
Design a program using an array that lists even numbers and odd numbers separately from the 12 numbers supplied by a user.  7
HOW TO HANDLE EXCEPTIONS IN C  5
How can we see the Expanded source code and compiled code for our source program in C?  1
Can we include one C program into another C program if yes how? Infosys4
what is the hexidecimal number of 4100? Google14
To find whether a number is even or odd without using any conditional operator?? IBM4
simple c program for 12345 convert 54321 with out using string  5
what is the difference between getch() and getchar()?  5
write a program to find out number of on bits in a number? Huawei12
Given a single Linked list with lakhs of nodes and length unknown how do you optimally delete the nth element from the list? Oracle1
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com