C++ program to swap the values of two variables if values of both variables are not the same

By Prof. Fazal Rehman Shamil
Last modified on December 24th, 2019

Write a C++ program to swap the values of two variables if values of both variables are not the same using a switch statement

e.g

before swapping : a=5; b=6

after swapping:  a=6, b=5

logic of swaping program

Flowchart of the program to swap the values of two variables using the switch statement

C++ program to swap the values of two variables if values of both variables are not the same

C++ Source Code to swap the values of two variables using the switch statement

Output

Please input the value of a :

6

Please input the value of b :

9

After Swap

a: 9

b: 6

SFT (Shamil’s Flow Table )

Are you interested to Read about SFT(Shamil’s Flow Table)?

Explanation of the program to swap the values of the variables using the switch statement

Prof.Fazal Rehman Shamil (Available for Professional Discussions)
1. Message on Facebook page for discussions,
2. Video lectures on Youtube
3. Email is only for Advertisement/business enquiries.