Maruti Suzuki Interview Question

Swap two numbers without using third variable

Interview Answer

Anonymous

Sep 11, 2024

// Let the two numbers be a and b a = a + b; // Step 1: Add both numbers b = a - b; // Step 2: Subtract b from the sum to get a a = a - b; // Step 3: Subtract the new b from the sum to get b