PuzzlersWorld.com

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

Swap two integer variables

November 3, 2012 by asinghal Leave a Comment

How to swap two integer variables without using the third variable ?
See Solution: Swap two integer variablesHide Solution

I know three solutions, comment if you know more 🙂

Solution 1:

x = x+y;
y  = x-y;
x  = x-y;

Solution 2:

y = 2*((x+y)/2) – (x =y);

Solution 3:

x = x^y;
y = x^y;
x = x^y;

Note: However solution 1 & 2 has problem of overflow doing addition of two integers might overflow. But solution 3 will not have any such problem

Checkout more Interview Questions Tags: Easy, Interview, Solved Puzzles

You eat something you neither plant nor plow

October 20, 2012 by puzzler 1 Comment

You eat something you neither plant nor plow.
It is the son of water, but if water touches it, it dies.

Tried enough already?

Checkout more Riddles Tags: Easy, Solved Puzzles

I am mother and father

September 2, 2012 by Ankur 1 Comment

I am mother and father,
but never birth or nurse.
I’m rarely still, but I never wander.
What am I?

Tried enough already?

Checkout more Riddles Tags: Easy, Solved Puzzles

What walks on four legs in its initial years

September 2, 2012 by Ankur 1 Comment

What walks on four legs in its initial years,
two in its mid-years,
and three in its later years?

Tried enough already?

Checkout more Riddles Tags: Easy, Solved Puzzles

Pronounced as one letter, And written with three

September 2, 2012 by Ankur 1 Comment

Pronounced as one letter,
And written with three,
Two letters there are,
And two only in me.
I’m double, I’m single,
I’m black, blue, and gray,
I’m read from both ends,
And the same either way.
What am I?

Tried enough already?

Checkout more Riddles Tags: Easy, Solved Puzzles

If following is true, then what is value of 6?

September 2, 2012 by Ankur 1 Comment

If following is true, then what is value of 6?
1=3
2=3
3=5
4=4
5=4
6=?

Tried enough already?
See Explanation: If following is true, then what is value of 6?Hide Solution
Answers is 3.
1 = one = 3 letters
2 = two = 3 letters
3 = three = 5 letters
4 = four = 4 letters
5 = five = 4 letters
6 = six = 3 letters
Cheers 🙂

Checkout more Riddles Tags: Easy, Puzzle, Solved Puzzles

What makes your left hand, your right?

September 2, 2012 by Ankur 1 Comment

What makes your left hand, your right?

Tried enough already?

Checkout more Riddles Tags: Easy, Solved Puzzles

I do not fly, though some claim I do

September 2, 2012 by Ankur 2 Comments

I do not fly, though some claim I do.
I do not stand still, yet it may seem I do.
You cannot stop me, no matter how hard you try.
What am I?

Tried enough already?

Checkout more Riddles Tags: Easy, Solved Puzzles

A certain crime is punishable if attempted

September 2, 2012 by Ankur 1 Comment

A certain crime is punishable if attempted but not punishable if committed.
What is it?

Tried enough already?

Checkout more Riddles Tags: Easy, Solved Puzzles

What is always coming but never truly arrives?

September 1, 2012 by Ankur 1 Comment

What is always coming but never truly arrives? 

Tried enough already?

Checkout more Riddles Tags: Easy, Solved Puzzles

  • « Previous Page
  • 1
  • …
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 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