# Thread: Need a C program for the following question

1. ## Need a C program for the following question

You have ten boxes, each of which contains nine balls. The balls in one box each weigh 0.9pounds;the balls in all the other boxes weigh exactly one pound each. You have an accurate scale in front of you, with which you can determine the exact weight, in pounds, of any given set of balls. How can you determine which of the ten boxes contains the lighter balls with only one weighing ?

2. That's not how it works around here.

Announcements - General Programming Boards

3. This seems a math problem in logical thinking, rather than a programming problem.

4. Take 1 ball from box #1,
take 2 balls from box #2,
...
take no balls from box #10.
Put all 45 balls on the scale.

If the fractal part of total weight is:
.0 : found box #10
.1 : found box #9
...
.9 : found box #1

Now try to write the program on your own, paste the code and ask some questions if you will have any.

5. This is a typical interview question, and not usually code-related.