Showing posts with label puzzle. Show all posts
Showing posts with label puzzle. Show all posts

Thursday, February 24, 2011

Boolean

Here's a very simple program with standard questions :)

Question 1> : Is there anything wrong with this code ?
Question 2> : Will this code compile ?
Question 3> : Are there any specific options that I should give for compiling it ?
Question 4> : What is the output of this program ?



Tuesday, June 1, 2010

Find the value of the modified string

This is my favorite question. Its so much fun to listen to all the different answers and their logical explanations :)

Question

If my C program contains only the following 2 statements ( inside main function ofcourse !! ), then what is the value of the string pointed by "x", after the execution of these 2 statements.


Answer


Please follow this link to post your answer. I shall update this post with the correct answer in about a week's time.

Friday, May 28, 2010

(x-a)(x-b)(x-c)....(x-z)

Update : This puzzle is now solved

I consider this to be one of the more silly puzzle questions :p

Question

What is the value of this multiplication :

(x-a)(x-b)(x-c).....(x-z)

Answer

As rightly pointed out by Ajay and Kalpana, the answer is "zero".

The reason being, x-x = 0

Thursday, April 29, 2010

Find the box containing 9 grams gold coin

Puzzle : 


Update : This puzzle is solved now

There are 5 boxes. Each box contains 10 gold coins. 
4 of the boxes contain gold coins weighing 10 grams each. 
One of the box contains gold coins that weigh 9 grams each. 
You are allowed to open the boxes if needed. 
But, the gold coins are completely identical and the difference in their weight cannot be identified by the naked eye. 
You are given a digital weighing machine.

Find out the box that contains the 9 grams gold coins by using the weigh only once.

Solution : 


Lets label the 5 boxes as A,B,C,D and E


Now pick 1 gold coin from box A, 2 from box B, 3 from box C, 4 from box D and 5 from box E
Keep them on the weighing machine and find out the total weight.
If all the boxes contained gold coins that weighed 10 grams each, then the weight would be :

10 + 20 + 30 + 40 + 50 = 150 grams.

But, since one box contains all the gold coins weighing 9 grams, based on the box that contains this defective gold coin the measured weight would vary.

If box A contained the 9 gram gold coins, the measured weight would be :

9 + 20 + 30 + 40 + 50 = 149 grams.

Following the same logic, based on the single measured weight we can identify the box that contains 9 grams gold coin as below :

If measured weight is 149 grams, then the 9 gram gold coin is in box A.
If measured weight is 148 grams, then the 9 gram gold coin is in box B.
If measured weight is 147 grams, then the 9 gram gold coin is in box C.
If measured weight is 146 grams, then the 9 gram gold coin is in box D.
If measured weight is 145 grams, then the 9 gram gold coin is in box E.