C++ Program to Swap two Numbers using Third Variable

Swap two Numbers using Third Variable

Here you will learn and get example code of C++ Program to Swap two Numbers using Third Variable.

This is the simple swapping method program using third variable. This program can be done by without using third variable. Here we are using a temp variable, Which is used to change the values of two variables. Let’s understand this simple swapping method by example.

for example:-

to Swap two Numbers using Third Variable formula

a=5 and b=10

temp=a;

a=b;

b=temp;

Program to Swap two Numbers using Third Variable

Output

to Swap two Numbers 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