Thread: Need a C program for the following question

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    1

    Smile 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. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    That's not how it works around here.

    Announcements - General Programming Boards

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    This seems a math problem in logical thinking, rather than a programming problem.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Jun 2009
    Posts
    120
    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. #5
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    This is a typical interview question, and not usually code-related.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about c program
    By TexasKid in forum C Programming
    Replies: 19
    Last Post: 04-22-2012, 09:12 AM
  2. Have a question on my program
    By zach48191 in forum C Programming
    Replies: 4
    Last Post: 10-12-2011, 09:56 PM
  3. Question about K&R program
    By Aerie in forum C Programming
    Replies: 15
    Last Post: 04-24-2005, 07:09 AM
  4. Program question--need help!!!
    By Jedijacob in forum C Programming
    Replies: 5
    Last Post: 11-30-2004, 12:07 PM
  5. Got a question about a program...
    By Phantasmagoria in forum Game Programming
    Replies: 1
    Last Post: 12-19-2003, 09:32 PM

Tags for this Thread