PuzzlersWorld.com

  • Hacker Puzzle
  • Interview Puzzles
  • Number Puzzles
  • Maths Puzzles

How to measure 4 gallon of water

November 1, 2012 by asinghal 2 Comments

How to measure exactly 4 gallon of water from 3 gallon and 5 gallon jars, Given, you have unlimited water supply from a running tap.

It was also solved by Bruce Willis in one of his Die Hard movie to stop a bomb.

See Solution: How to measure 4 gallon water from 3 gallon and 5 gallon jarHide Solution
There are 2 possible solutions i can think of

Solution 1:

  1. Fill 3 gallon jar with water.
  2. Pour all its water into 5 gallon jar.
  3. Fill 3 gallon jar again.
  4. Pour its water into 5 gallon jar untill it is full. Now you will have exactly 1 gallon water remaining in 3 gallon jar.
  5. Empty 5 gallon jar, pour 1 gallon water from 3 gallon jar into it. Now 5 gallon jar has exactly 1 gallon of water.
  6. Fill 3 gallon jar again and pour all its water into 5 gallon jar, thus 5 gallon jar will have exactly 4 gallon of water.

Solution 2:

  1. Fill 5 gallon jar.
  2. Pour all its water to 3 gallon jar, thus leaving exactly 2 gallon water in 5 gallon jar.
  3. Empty 3 gallon jar and pour all of 5 gallon jar water into it, thus now 3 gallon jar will have exactly 2 gallon of water.
  4. Fill 5 gallon jar again and pour its water to 3 gallon jar until that is full. So exactly 4 gallon water will remain in 5 gallon jar.

Checkout more Logical Puzzles Tags: Interview, medium, Solved Puzzles

Four How many squares are there

October 28, 2012 by asinghal 30 Comments

1.)

how many squares are in this picture

how many squares are in this picture

See AnswerHide Answer

There are total of 40 squares.

How?
Let’s assume the smallest square side is 0.5cm in length.

Now count the squares with different length :-
0.5cm : 8
1cm : 16 +2(in the middle)
2cm : 9
3cm : 4
4cm : 1
————
Total : 40

2.) How many squares are in this picture ?

how many squares

how many squares in this picture

See AnswerHide Answer
There are total of 16 squares.
How?

Lets count…
Squares with side length equal to 1 matchstick: 9
Squares with side length equal to 2 matchsticks: 5(2+1+2)
Square with side length equal to 3 matchsticks: 1 (This is difficult to find, and easy to miss)
Square with side length equal to 4 matchsticks: 1 (Everybody knows)
So total number of squares : 16

This image(courtsey Charles on facebook) explains it all:-

How many squares matchstick solution

How many squares matchstick solution

[Read more…]

Checkout more Picture Puzzles Tags: How Many, How Many Squares, Puzzle, Solved Puzzles

Objective Questions set C/C++ – Part 5

October 28, 2012 by asinghal Leave a Comment

4 Objective type interview questions on C/C++ with answers

Before you start:-

  1. You can check your answer by filling a,b,c,d or e in the text box.
  2. You can get the answer by clicking Give Up Button.

Try yourself before giving up 🙂

Q1)

#include
int main(){
    char a[5]="hello";
    printf("%s",a);
}

Options: a) will print “hello” only b) will print some garbage values c) will print “hello” atleast d) None

Tried enough already?
[Read more…]

Checkout more Interview Questions Tags: C/C++, Interview, Solved Puzzles

Objective Questions set C/C++ – Part 4

October 28, 2012 by asinghal 5 Comments

10 Objective type interview questions with answers on C/C++

Before you start:-

  1. You can check your answer by filling a,b,c,d or e in the text box.
  2. You can get the answer by clicking Give Up Button.

Try yourself before giving up 🙂

Q1)

#include
main()
{
    unsigned char i;
    int sum=0;
    for(i=0;i<300;i++)
        sum=sum+i;
    printf("%d",sum);
}

Options: a) 44850 b) 45150 c) 300 d) Infinite Loop

Tried enough already?

Q2)

#include
fun(int i)
{
    int j=0;
    while (i & i-1) {
        j++;   
    }
    printf("%d",j);
}

main(){
    f(100);
}

Options: a. 100 b. 99 c. 2 d. 3

Tried enough already?

Q3)

Code 1 :
        for(i=0; i<1000; i++)
                for(j=0; j<100; j++)
                        x = y;

Code 2 :
        for(i=0; i<100; i++)
                for(j=0; j<1000; j++)
                        x = y;

Which code will execute faster ?
[Read more…]

Checkout more Interview Questions Tags: C/C++, Interview, Solved Puzzles

Objective Questions set C/C++ – Part 3

October 28, 2012 by asinghal 1 Comment

10 Objective type interview questions with answers on C/C++

Before you start:-

  1. You can check your answer by filling a,b,c,d or e in the text box.
  2. You can get the answer by clicking Give Up Button.

Try yourself before giving up 🙂

Q1) What will the below program prints ?

#include
void e( int );
main( )
{
    int a;
    a=3;
    e(a);
}

void e(int n)
{
    if (n>0)
    {
        e(--n);
        printf("%d",n);
        e(--n);
    }
}

Options: a) 0120 b) 0121 c) 0201 d) 0211

Tried enough already?
Q2)

#include
main( )
{
    int a[5]= {1,2,3,4,5};
    int*ptr = (int*)(&a+1);
    printf("%d %d", *(a+1), *(ptr-1));
}

Options: a)2 2 b) 2 1 c) 2 5 d) None

Tried enough already?
Q3)

#include
void foo(int [][3]);
main( )
{
    int a[3][3]={ {1,2,3}, {4,5,6}, {7,8,9} };
    foo(a);
    printf("%d", a[2][1]);
}

void foo(int b[][3])
{
    ++b;
    b[1][1]=35;
}

Options: a)8, b) 9, c) 7, d)35

Tried enough already?
Q4)
If performance is a critical requirement, then storage class should be used is ?
a)auto b) register c) extern d) static
Tried enough already?

Q5)
In a program
1-> char str1[ ] = “abc”;
2-> char *str2 = “xyz”;
3-> str2 = str1;
4-> str1 = str2;

Options:
a)compile error at line 3
b)compile error at line 4
c)no problem in the code
d)run time error

Tried enough already?

Q6)

int A = sizeof(char*)
int B = sizeof(int*)

a)A=B b)A<B c)A>B d) depends on compiler

Tried enough already?

Q7)

void func (int y)
{
static int x;
.
.
.
}

x and y will be stored on respectively in ?

Options:
a) stack and heap b) stack and data section c) data section and stack d) heap and data section

Tried enough already?

Q8)

#include

main(){
    int i=5;
    ++i++;
    printf("%d", i);
}

Options:
a)5 b) 6 c) 7 d) compilation error

Tried enough already?

Q9)
Statement 1-> const char *p1=”hello world”;
Statement 2-> char *const p2=”hello world”;
Statement 3-> p1=”welcome”;
Statement 4-> p2=”good bye”;
Statement 5-> *(p1+3) = ‘A’;
Statement 6­-> *(p2+3) = ‘A’;

Which statement cause problem ?

Options: a)4 & 5 b) 1 & 3 c) 3 & 5 d) 2 & 3

Tried enough already?

Q10)

#include
int function()
{
    static int a=0;
    a=a+1;
    return a;
}

main()
{
    function();
    function();
    printf("%d", function());
}

Options: a) 1 b) 2 c) 3 d) None

Tried enough already?

Checkout more Interview Questions Tags: C/C++, Interview, Solved Puzzles

Objective Questions set C/C++ – Part 2

October 28, 2012 by asinghal Leave a Comment

10 Objective type interview questions with answers on C/C++

Before you start:-

  1. You can check your answer by filling a,b,c,d or e in the text box.
  2. You can get the answer by clicking Give Up Button.

Try yourself before giving up 🙂

Q1)

#include
struct XX{
    int a:10;
    int b:6;
    char c;
} structure;
int main(){
    int i = sizeof(structure);
    printf("%d", i);
}

Options: a) 4 b) 8 c) 9 d) 3 e) Compilation error

Tried enough already?

Q2)

#include
#include
main()
{
    char *s;
    s="hot java";
    strcpy(s,"solaris java");
    printf("%s", s);
}

Options:a) hot java b) solaris java c) compilation error d) Segmentation fault

Tried enough already?
[Read more…]

Checkout more Interview Questions Tags: C/C++, Interview, Solved Puzzles

Objective Questions set C/C++ – Part 1

October 28, 2012 by asinghal Leave a Comment

10 Objective type interview questions with answers on C/C++

Before you start:-

  1. You can check your answer by filling a,b,c,d or e in the text box.
  2. You can get the answer by clicking Give Up Button.

Try yourself before giving up 🙂

Q1) What will be the output of the program below

#include
main(){
    int num[] = {1,4,8,12,16};
    int *p,*q;
    int i;
    p =  num;
    q = num+2;
    i = *p++;
    printf("%d, %d, %d\n",i, *p, *q);
}

Options a) 4, 4, 8 b) 1, 4, 8 c) 2, 1, 8 d) 2, 4, 8

Tried enough already?
Q2) What will be the output of the program below

#include

main(){
char *a[4]={"jaya","mahesh","chandra","swapant"};
int i = sizeof(a)/sizeof(char *);
printf("i = %d\n", i);
}

Options: a) 4 b) 7 c) 8 d) 1

Tried enough already?
[Read more…]

Checkout more Interview Questions Tags: C/C++, Interview, Solved Puzzles

Puzzling Choices

October 28, 2012 by asinghal Leave a Comment

Are you making the right choice?

Tea or coffee? Walking or running? We are faced with so many lifestyle choices throughout the day, but how do you know you are making the right choice? Here is what experts say on Times of India article..

TEA OR COFFEE?

“Black tea usually has far less caffeine than coffee, while green tea is also packed with heart-healthy antioxidants.” says Kate Cook, nutrition coach. “Coffee acts a bit like rocket fuel, kick-starting adrenal glands and triggering the release of stress hormone, cortisol. Not the best start to the day.
Answer: Tea

FRUIT JUICE OR FRUIT?

“The fibre in fruits make it far more satisfying and filling with fewer calories.” says Kate. “Fruit juices have the fibre removed and tend to be loaded with sugar, which sends blood sugar level soaring — and then crushing.”
Answer: Fruit

EXERCISE IN THE MORNING OR EVENING?

“Studies shows that morning exercises are far more likely to stick with it,” explains Janey Holiday, fitness instructor: “You’re also likely to have a healthier day –from the food choices you make to how you feel mentally because of the endorphins flowing throughout your body. While exercise helps you sleep better; working out too late in the evening will actually disturb your sleep.”
Answer: Morning
[Read more…]

Checkout more Miscellaneous Tags: Solved Puzzles

3 bulbs and 3 switches

October 26, 2012 by asinghal 4 Comments

There are 3 bulbs(B1, B2 and B3) in a room on 1st floor, they can be operated using 3 switches(S1, S2, S3) present on the ground floor. You don’t know which Switch is for which bulb. How can you figure out, which switch is for which bulb if you are allowed to visit 1st floor only once.

Think before you give up, its really possible.

See Solution : 3 bulbs and 3 switchesHide Solution
Assuming all switches are turned off initially, You can do the following:-
1.) Turn on switch S1 for 5 minutes.
2.) Turn Off switch S1.
3.) Turn on switch S2.
4.) Go Upstairs.
5.) Glowing bulb can be assigned to Switch S2.
6.) Touch both other bulbs, hotter one should be assigned to switch S1 and the other one to switch S3.

Checkout more Logical Puzzles Tags: Puzzle, Solved Puzzles

Red and blue balls

October 25, 2012 by asinghal 1 Comment

You have three bags and three labels. One bag has only red balls, one has only blue balls and one has both red and blue balls. Three labels are R, B and RB. R label was meant for the bag with only red balls, B label was meant for the bag with only blue balls and RB for the bag with both red and blue balls. Ram by mistake labelled the bags wrongly such that all the labels are wrong, how many minimum number of balls he should pick and from what bags to correct the labels? It is given that each bag has unlimited number of balls to be picked.

See Solution : Red and blue ballsHide Solution
The minimum number of balls he should pick is 1 from the bag with label RB.

How ?

As the label of all the bags are wrong, bag with label RB can either have all red balls or all blue balls.

Now ram will either get red ball or the blue ball.

Case 1: Ram gets the red ball
Bag with label RB is the bag with all the red balls(R).
Bag with label B can either be RB or R(as all the labels are wrong) but as we already know R bag so it can only be RB.
We know 2 bags correctly so third bag with label R should be B.

Case 2: Ram gets the blue ball
Bag with label RB is the bag with all the blue balls(B).
Bag with label R can either be B or RB(as all the labels are wrong) but as we already know B bag so it can only be RB.
we know 2 bags correctly so third bag with label B should be R.

Checkout more Interview Puzzles Tags: Interview, Puzzle, Solved Puzzles

  • « Previous Page
  • 1
  • 2
  • 3
  • Next Page »
Submit your Puzzle

You may also like

    Categories

    • Aive hi Puzzles
    • Akbar and Birbal
    • Alphabetical Puzzles
    • Bollywood Puzzles
    • Google Code jam
    • Hindi Riddles
    • Interview Puzzles
    • Interview Questions
    • Logical Puzzles
    • Malayalam Puzzles
    • Maths Puzzles
    • Miscellaneous
    • Number Puzzles
    • Picture Puzzles
    • Riddles
    • Tamil Puzzles
    • Technical

    Social

    • View puzzlersworld’s profile on Twitter
    privacy policy

    Copyright © 2025 · eleven40 Pro Theme on Genesis Framework · WordPress · Log in

    • Hacker Puzzle
    • Logo Puzzles
    • Optical Illusions
    • WhatsApp Puzzles
    • Picture Puzzles
    • Riddles
      ▼
      • Hindi Riddles
    • Bollywood Puzzles
    • Alphabetical Puzzles
    • Aive hi Puzzles
    • Interview Puzzles
    • Logical Puzzles
    • Interview Questions
      ▼
      • Data Structures
      • Binary Tree
      • Algorithms
      • Recursion Questions
      • Amazon Interview Questions
      • Snapdeal Interview Questions
      • Google Code jam
    • Technical
    • Akbar and Birbal
    • Number Puzzles
    • Maths Puzzles
    • Miscellaneous