technical interview Q & A for high-tech professionals
Interview Questions
Electronics Hardware
Computer Software
Quick Thinking Tests
General questions
Phone screening questions
Submit your Q or A

Technical articles
Technical discussion
Resume and interview
How to get a job in Silicon Valley
How much are you worth on market?
Why you may need an agent

Break point
Written Exam
Logic Tests
Professional Test
Tomato company
Cup of coffee
How stock market works
Engineering jokes

About Hitequest
About Hitequest
Home page


=Computer Software Questions=


There are two integers a and b. How to exchange the contents of them without using a third one?

A1: submitted by Anonimous1

The answer is to do the following:

int a = 7, b = 4;
b = a * b; // b = 28
a = b/a;   // a = 4
b = b/a;   // b = 7


A2: submitted by jhudzik

This will work:

  a = a + b
  b = a - b
  a = a - b



I see a problem there..
Var "a" can overflow, and the data will be corrupted.
This may be better:

  a = a - b
  b = a + b
  a = b - a