Like Tree1Likes
  • 1 Post By Salem

Need a C program for the following question

This is a discussion on Need a C program for the following question within the C Programming forums, part of the General Programming Boards category; You have ten boxes, each of which contains nine balls. The balls in one box each weigh 0.9pounds;the balls in ...

  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
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,651
    That's not how it works around here.

    Announcements - General Programming Boards

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,656
    This seems a math problem in logical thinking, rather than a programming problem.
    rags_to_riches likes this.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    DRK
    DRK is offline
    Registered User
    Join Date
    Jun 2009
    Posts
    109
    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
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,651
    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, 11:07 AM
  5. Got a question about a program...
    By Phantasmagoria in forum Game Programming
    Replies: 1
    Last Post: 12-19-2003, 08:32 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21