---
title: "Swapping of two(2) numbers without using third variable?"  
description: "Swapping of two(2) numbers without using third variable?"  
author: "Hemant Patel"  
published: 2017-02-15  
updated: 2017-02-17  
canonical: https://www.mindstick.com/forum/34256/swapping-of-two-2-numbers-without-using-third-variable  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Swapping of two(2) numbers without using third variable?

.

## Replies

### Reply by Hemant Patel

```
//Initialize two variablesX=10 and Y=20   //Sum value of X & Y and assign into X  X=X+Y                 
  =10+20   =30//Subtract Y from new value of X=30 and assign into YY=X-Y  =30-20  =10//Subtract new value of Y=10 from X=30 and assign into XX=X-Y  =30-10  =20FINAL VALUE OF X IS 20 AND Y IS 10(X=20 and Y=10)  
```


---

Original Source: https://www.mindstick.com/forum/34256/swapping-of-two-2-numbers-without-using-third-variable

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
