C++ Program to Swap Two Numbers Without using Third Variable

Swap Two Numbers Without using Third Variable

Here you will learn a new method that can change the values of two variable without using third variable.  We will implement this by C++ Program to Swap Two Numbers Without using Third Variable. Let’s understand this simple swapping method by example.

Example:-

x=5 and y=10

x = x + y;

y = x – y;

x = x – y;

C++ Program to Swap Two Numbers Without using Third Variable

Output

C++ Program to Swap Two Numbers Without using Third Variable

 

 

 

Check out our other C++ programming Examples

 

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top