write a program to find out number of on bits in a number?
Answer Posted / arijit
#include<stdio.h>
#include<conio.h>
void main()
{
int n,cnt,rem
scanf("%d",&n);
cnt=0;
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 | 0 No |
Post New Answer View All Answers
What is ponter?
What are the different types of linkage exist in c?
What is the difference between arrays and pointers?
What is binary tree in c?
Program will then find the largest of three numbers using nested if-else statements. User is prompted to enter three numbers. Program will find the largest number and display it on the screen. All three numbers entered by the user are also displayed. If user enters 21, 33, and 5, the output should be as follows: You entered: 21, 33 and 5. The largest number is 33.
In c programming typeing to occupy the variables in memory space. if not useing the variable the memory space is wasted.ok, how to avoid the situation..? (the variable is used & notused)
How can I call a function with an argument list built up at run time?
If errno contains a nonzero number, is there an error?
What is meant by high-order and low-order bytes?
What are the different types of errors?
a=10;b= 5;c=3;d=3; if(a printf(%d %d %d %d a,b,c,d) else printf("%d %d %d %d a,b,c,d);
Explain 'bus error'?
Explain what are reserved words?
Why can’t we compare structures?
explain how do you use macro?