# Measuring Time Logic Puzzle

You are given with two ropes with variable width. However if we start burning both the ropes, they will burn at exactly same time i.e. an hour. The ropes are non-homogeneous in nature. You are asked to measure 45 minutes by using these two ropes.

How can you do it?

Please note that you can’t break the rope in half as it is being clearly stated that the ropes are non-homogeneous in nature.

Solution:
45 minutes

Explanation :
All you have to do is burn the first rope from both the ends and the second rope from one end only simultaneously. The first rope will burn in 30 minutes (half of an hour since we burned from both sides) while the other rope would have burnt half. At this moment, light the second rope from the other end as well. Where, the second rope would have taken half an hour more to burn completely, it will take just 15 minutes as we have lit it from the other end too.

Thus you have successfully calculated 30+15 = 45 minutes with the help of the two given ropes.

# Popular Deductive Logic Problem

Eight Brothers lives in an old house where there is no electricity and no computers or any any other gadget.

Brother-2: Playing Chess
Brother-3: Writing
Brother-4: making food for the family
Brother-5: sleeping and snoring
Brother-6: cleaning house
Brother-7: watering the plants

what is Brother-8 doing ?

Solution:
Playing chess

Game needs two players so Brother-8 is playing chess with Brother-2

# Knockout Matches Logical Problem

Let us say that a table tennis tournament was going on with knock out terms which means the one who loses the match is out of the tournament. 100 players took part in that tournament.

How many matches were played?

Solution:
99 matches.

The number of matches will always sum up to one less than the number of players in a knock out tournament. You may calculate it in any manner. Thus 99 matches were played.

# Hard Logic Brain Teaser

There are 100 doors. 100 strangers have been gathered in the adjacent room. The first one goes and opens every door. The second one goes and shuts down all the even numbered doors – second, fourth, sixth... and so on. The third one goes and reverses the current position of every third door (third, sixth, ninth… and so on.) i.e. if the door is open, he shuts it and if the door is shut, he switches opens it. All the 100 strangers progresses in the similar fashion.

After the last person has done what he wanted, which doors will be left open and which ones will be shut at the end?

Solution:
Think deeply about the door number 56, people will visit it for every divisor it has. So 56 has 1 & 56, 2 & 28, 4 & 14, 7 & 8. So on pass 1, the 1st person will open the door; pass 2, 2nd one will close it; pass 4, open; pass 7, close; pass 8, open; pass 14, close; pass 28, open; pass 56, close.
Thus we can say that the door will just end up back in its original state for each pair of divisor. But what about the cases in which the pair of divisor has analogous number for example door number 16? 16 has the divisors 1 & 16, 2 & 8, 4&4. But 4 is recurrent because 16 is a perfect square, so you will only visit door number 16, on pass 1, 2, 4, 8 and 16… leaving it open at the end. So only perfect square doors will remain open at the end.

# 3 Gallon Brain Teaser

You have been given three jars of 3 liters, 5 liters and 8 liters capacity out of which the 8 liters jar is filled completely with water. Now you have to use these three jars to divide the water into two parts of 4 liters each.

How can you do it making the least amount of transfers?

Solution:
8 liters jar: 8; 5 liters jar: 0; 3 liters jar: 0
Fill 5 liters jar entirely.
8 liters jar: 3; 5 liters jar: 5; 3 liters jar: 0
Fill 3 liters jar with 5 liters jar.
8 liters jar: 3; 5 liters jar: 2; 3 liters jar: 3
Pour entirely from 3 liters jar to 8 liters jar.
8 liters jar: 6; 5 liters jar: 2; 3 liters jar: 0
Pour entirely from 5 liters jar to 3 liters jar.
8 liters jar: 6; 5 liters jar: 0; 3 liters jar: 2
Fill 5 liters jar with water from 8 liters jar.
8 liters jar: 1; 5 liters jar: 5; 3 liters jar: 2
Fill the 3 liters jar with water from the 5 liters jar.
8 liters jar: 1; 5 liters jar: 4; 3 liters jar: 3
Empty 3 liters jar in 8 liters jar.
8 liters jar: 4; 5 liters jar: 4; 3 liters jar: 0

Now you have 4 liters of water in 8 liters jar as well as 5 liters jar.

# Fake Coin Brain Teaser

In front of you, there are 9 coins. They all look absolutely identical, but one of the coins is fake. However, you know that the fake coin is lighter than the rest, and in front of you is a balance scale. What is the least number of weightings you can use to find the counterfeit coin?

Solution:
The answer is 2. First, divide the coins into 3 equal piles. Place a pile on each side of the scale, leaving the remaining pile of 3 coins off the scale. If the scale does not tip, you know that the 6 coins on the scale are legitimate, and the counterfeit is in the pile in front of you. If the scale does tip, you know the counterfeit is in the pile on the side of the scale that raised up. Either way, put the 6 legitimate coins aside. Having only 3 coins left, put a coin on each side of the scale, leaving the third in front of you. The same process of elimination will find the counterfeit coin.

# Funny Brain Twister

We all know that New Year occurs after a week from Christmas and thus it falls on the same day as of Christmas. But this will not happen in 2050. In 2050, Christmas will appear on Sunday while New Year will appear on Saturday.

How can this be possible ?

Solution:
Read the question carefully again. New Year do falls after Christmas but that happens if two different years. The question is put up against the year 2050 and thus there will be 51 weeks and 2 days in between them as New Year will appear on 1 January 2050 and Christmas will happen on 25 December 2050.

# Most Popular Logical Puzzle

Outside a room there are three light switches. One of switch is connected to a light bulb inside the room.
Each of the three switches can be either 'ON' or 'OFF'.

You are allowed to set each switch the way you want it and then enter the room(note: you can enter the room only once)

Your task is to then determine which switch controls the bulb ??

Solution:
Set the first switches on for abt 10min, and then switch on the second switch and then enter the room.
Three cases are possible
1.Bulb is on => second switch is the ans
2.Bulb is off and on touching bulb , you will find bulb to be warm
=>1st switch is the ans.
3.Bulb is off and on touching second bulb , you will find bulb to be normal(not warm)
=>3rd bulb is the ans.

# Famous Probability Puzzle

This is a famous probability puzzle in which you have to choose the correct answer at random from the four options below.
Can you tell us whats the probability of choosing correct answer in this random manner.

1) 1/4
2) 1/2
3) 1
4) 1/4

Solution:
0%

Explanation:
1) why cant be 1/4 : If the answer is 1/4, then as we know two out of four answer choices is '1/4', the answer has be 1/2.

2) why cant be 1/2 : If the answer is 1/2 then because answer:"1/2" is 1 out of 4 answer choices, the answer must be 1/4. This is also a contradiction. So the answer cannot be 1/2.

3) why cant be 1 : If the answer is 1 then because answer:"1" is 1 out of 4 answer choices, the answer must be 1/4. Again the same contradiction and therefore answer cannot be 1

# Awesome Probability Logic Riddle

You need to divide 50 marbles(25-red and 25-blue) into two boxes such that the probability of picking red marble is maximized.

Following conditions need to hold true :
1. None of box is empty
2. All the marbles must be in one of two boxes.

Solution:
Put one red marble in one box and all other marbles in the 2nd box.

Probability :
50 + 24/49

1. This comment has been removed by the author.

### C Questions

C Questions
C Questions

Note : All the programs are tested under Turbo C/C++ compilers.
It is assumed that,
Programs run under DOS environment, The underlying machine is an x86 system, Program is compiled using Turbo C/C++ compiler.
The program output may depend on the information based on this assumptions (for example sizeof(int) == 2 may be assumed).
Predict the output or error(s) for the following:

void main()
{
int const * p=5; printf("%d",++(*p));
}
Compiler error: Cannot modify a constant value.
Explanation:
p is a pointer to a "constant integer". But we tried to change the value of the "constant integer".
main()
{
char s[ ]="man"; int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}
aaaa nnnn
Explanation

### Zoho Interview | Set 1 (Advanced Programming Round)

Third Round: (Advanced Programming Round) Here they asked us to create a “Railway reservation system” and gave us 4 modules. The modules were:
1. Booking
2. Availability checking
3. Cancellation
4. Prepare chart
We were asked to create the modules for representing each data first and to continue with the implementation phase.

My Solution :