Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write a program to find out number of on bits in a number?

Answer Posted / anu

#include<stdio.h>
#include<conio.h>
void main()
{
int n,cnt,rem
scanf("%d",&n);
cnt=1;
while(n!=0)
{
rem=n%2;
n=n/2;
cnt++;
}
printf("number of bits of the number is = %d",cnt);
getch();
}

Is This Answer Correct ?    0 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the meaning of typedef struct in c?

1116


What is putchar() function?

1222


Write a simple code fragment that will check if a number is positive or negative.

1211


.main() { char *p = "hello world!"; p[0] = 'H'; printf("%s",p); }

1374


Can 'this' pointer by used in the constructor?

1133


"C" language developed by "Dennis Ritchie" at AT & T. his remarks are a) too general, too abstract b) could deal with only specific problems c) lost generality of BCPL and B restored d) no remarks

1156


What is calloc()?

1133


How many levels of pointers can you have?

1251


Differentiate fundamental data types and derived data types in C.

1090


Tell us something about keyword 'auto'.

1109


Where local variables are stored in c?

1055


What is #ifdef ? What is its application?

1165


What are loops c?

1105


What is %s and %d in c?

1107


What is the -> in c?

1069