write a program to find out number of on bits in a number?
Answer Posted / kavitha
int setbit=1; //Lets start checking from first bit
int numBitSet=0; //Number of bits set in the number
while(setbit>0)
{
if(number&setbit) //bit wise and
numBitSet++;
setbit=setbit<<1;
}
Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
What are control structures? What are the different types?
How a string is stored in c?
Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?
What is the use of getchar() function?
Write a program to maintain student’s record. Record should
not be available to any unauthorized user. There are three
(3) categories of users. Each user has its own type. It
depends upon user’s type that which kind of operations user
can perform. Their types and options are mentioned below:
1. Admin
(Search Record [by Reg. No or Name], View All Records,
Insert New Record, Modify Existing Record)
2. Super Admin
(Search Record [by Reg. No or Name], View All Records,
Insert New Record, Modify Existing Record, Delete Single Record)
3. Guest
(Search Record [by Reg. No or Name], View All Records)
When first time program runs, it asks to create accounts.
Each user type has only 1 account (which means that there
can be maximum 3 accounts). In account creation, following
options are required:
Login Name: <6-10 alphabets long, should be unique>
Password: <6-10 alphabets long, should not display
characters when user type>
Confirm Password:
in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none
How do you construct an increment statement or decrement statement in C?
Write a program to check whether a number is prime or not using c?
What is extern storage class in c?
What are the two types of functions in c?
Tell us the use of fflush() function in c language?
Write a code of a general series where the next element is the sum of last k terms.
What are run-time errors?
Define C in your own Language.
How can I sort a linked list?