We have as unsigned character like obff and I want program to count no of 1s occur in that character.

Asked by Last Modified  

7 Answers

Follow 0
Answer

Please enter your answer

BEST Technical Trainer & Freelancer

Rotate right or left 8 times thriugh carry and check the flag each time...
Comments

Software Development Professional

unsigned int v; // count the number of bits set in v unsigned int c; // c accumulates the total bits set in v for (c = 0; v; v >>= 1) { c += v & 1; } The naive approach requires one iteration per bit, until no more bits are set. So on a 32-bit word with only the high set, it will go through...
read more
unsigned int v; // count the number of bits set in v unsigned int c; // c accumulates the total bits set in v for (c = 0; v; v >>= 1) { c += v & 1; } The naive approach requires one iteration per bit, until no more bits are set. So on a 32-bit word with only the high set, it will go through 32 iterations. Let me know if you need more detailed explaination. read less
Comments

Programming Guru

You can make a loop attached with a counter and shift right each time. loop testing condition should be (obff!=0). and with the help of count variable you can count number of one's.
Comments

One-to-One Computer & Programming Coaching | 14+ Years of Excellence

Dear Siddhant, I am sending a link that can help you to understand the link please open and try to learn, if is there any problem must reply me.. and don't confuse in unsigned int and unsigned char.. you can(put) unsigned char instead of unsigned int..
Comments

JAVA CLASSES IN BANGALORE

Contact me.
Comments

Programmer

Write a if condition that checks the every index of the string with 1. If the condition is true then increase the count variable value by one. Count variable must declared at the beginning of the program itself.
Comments

Programmer

Write a if condition that checks each and every index of string with 1 until u reach null termination . If the condition is true then increase the value of count variable by one. Count variable must be declared at the beginning of the program. At last print the count variable. That's it. Have fun with...
read more
Write a if condition that checks each and every index of string with 1 until u reach null termination . If the condition is true then increase the value of count variable by one. Count variable must be declared at the beginning of the program. At last print the count variable. That's it. Have fun with programs. read less
Comments

View 5 more Answers

Related Questions

Is doing MTECH from IIT's is as good as doing BTECH from the IIT's?
Yes , I prefer M.tech to be done only in IIT's and NIT's only. Masters is nothing but having an intensive research on one particular subject of your interest out of many streams in your specialisation....
Laxmi
0 0
8
How can I get admission for BTech in IIT?
You need to appear for JEE entrance exam after your 12th.
Yusufali
0 0
8
I am currently studying a BTech 3rd year (ECE). What is the future scope after completing the BTech?
if you are interested in core , try writting CDAC exam which is held twice a year , if you are interested in software courses , learn something from now which would help you in cracking interviews, and...
Saravana
0 0
5
How to join as a tutor I am Anusha of mechanical engineer I want to work in the UrbanPro as a tutor?
Hello. Welcome to urban pro. First create your account insurance pro which is free and as on us interest you can use premium member ship. And then after completing your profile you'll get enquiry when...
Anusha
What is the main difference between a BCA and a BTech?
My friend both of them are different streams BCA belong to the commerce stream and BTech belongs to Engineering stream.
Nemai
0 0
5

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

The Basic about modeling anything into CAD
The most basic problem that a beginner designer faces is - " From where to start" Have you ever wondered while starting to design an object to where should I start from or How am I suppose to know...

Skills of the Future
We are aware that Automation has entered every walk of life. We have to accept that it eliminates lower level jobs. Hence we have to adapt and acquire new skills. Broadly it can be classifed into five...

Some Interview Questions and Answers for fresher level on Pointers
What is a void pointer? Void pointer is a special type of pointer which can reference or point to any data type. This is why it is also called as Generic Pointer. As a void pointer can point to any data...

Difference between Engineering Mechanics and Mechanics of solids
Engineering mechnics (EM): 1.In EM deals with bodies as perfecly rigid bodies and also known as Mechanics of rigid bodies. 2. EM is the study of external forces that are acting on rigid body. 3....

Learning Tip - Project #1 Continuous Water Level Sensor
You can build a Continuous Water Level Sensor. You will need the followings 1. Stainless steel capacitive water level sensing probe 2. 555 Oscillator circuit 3. 89S52 microcontroller board with LCD...

Shyam Sunder Tiwari

0 0
0

Recommended Articles

MBA, Medicine and engineering are the three main professional courses in India. Engineering is still one of the highly sorted after professional courses in the under graduate level, while MBA is favoured as a preferred post graduate course. To shine in these courses, one needs to work and study hard. Engineering as a...

Read full article >

According to a recent survey conducted by the NCAER (National Council of Advanced Economic Research), engineering is the most sought after course in India. Some engineering courses are offered as BE or Bachelor of Engineering while some as Bachelor in Technology or B.Tech. Since engineering is a professional course, the...

Read full article >

Appearing for exams could be stressful for students. Even though they might have prepared well, they could suffer from anxiety, tension etc. These are not good for their health and mind. However, following a few exam preparation tips can save them from all these and help them to score good marks. Let’s find out all...

Read full article >

While schools provide formal education to the children, the home is where they start learning about things informally. Parents think that schools will take the initiative to educate their children. Well, this is partially true, as parents also play an essential role in bringing up their child. For the development of particular...

Read full article >

Looking for BTech Tuition ?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you