---
title: "Exchange Two integer variable value without using third variable."  
description: "Exchange Two integer variable value without using third variable."  
author: "Anonymous User"  
published: 2019-03-29  
updated: 2020-09-22  
canonical: https://www.mindstick.com/interview/23485/exchange-two-integer-variable-value-without-using-third-variable  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# Exchange Two integer variable value without using third variable.

```
public static void ExchangeInteger()
         {
             int a = 10;
             int b = 5;
             Console.WriteLine("a={0}", a);
             Console.WriteLine("b={0}", b);
             a = a + b; // Now a would be 15
             b = a - b; // Now b would be 15-5=10 ........
             a = a - b; // Now a would be 15-10=5........
             Console.WriteLine("a={0}", a);
             Console.WriteLine("b={0}", b);
             Console.ReadLine();
         }
```

\

\

## Answers

### Answer by Anonymous User

```
public static void ExchangeInteger()
         {
             int a = 10;
             int b = 5;
             Console.WriteLine("a={0}", a);
             Console.WriteLine("b={0}", b);
             a = a + b; // Now a would be 15
             b = a - b; // Now b would be 15-5=10 ........
             a = a - b; // Now a would be 15-10=5........
             Console.WriteLine("a={0}", a);
             Console.WriteLine("b={0}", b);
             Console.ReadLine();
         }
```

\

\


---

Original Source: https://www.mindstick.com/interview/23485/exchange-two-integer-variable-value-without-using-third-variable

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
