Swap Two Numbers With and Without Using Third Variable in Dart Programming
Hello everyone!
Today I am here to share with you an interesting program which is often asked in the practice questions and interviews. It is simple but many of us do not understand it. It is about how to swap two numbers without using the third variable.

Many of us has learnt swapping numbers by using the third new variable but it is worth understanding to swap two numbers with each other without using any new third variable.
Swap Two Numbers By Using Third Variable in Dart
It is very simple to swap two numbers with each other with the help of the third variable. So before moving to the swap of numbers without using third variable I will teach you to swap two numbers by using a third variable.

Here you can see that I have used a third variable temp to swap the numbers a and b with each other.
- I stored number
aintempvariable. - Then I stored the number
bina. - Then I assigned the value of
temptob.
In this way the swap was completed with the help of the third variable.
Swap Two Numbers Without Using Third Variable in Dart
It is very easy but a bit tricky to swap two numbers without using a third variable. In this way we use some basic arithmetic operations to swap both the numbers with each other.

Here you can see that I have swapped two numbers with each other without using the third variable. I used some arithmetic operations.
a = 10+20 = 30
b = 30-20 = 10
a = 30-10 = 20
So you can swap any two numbers with each other without using the third variable but with some basic maths calculations.
If you want to learn to swap two numbers with each other with and without using third variable then it may be the easiest example and explanation for you.
https://www.linkedin.com/feed/update/urn:li:share:7416414688592355329/
🎉 Congratulations!
Your post has been manually upvoted by the SteemX Team! 🚀
SteemX is a modern, user-friendly and powerful platform built for the Steem ecosystem.
🔗 Visit us: www.steemx.org
✅ Support our work — Vote for our witness: bountyking5
🎉 Congratulations, @mohammadfaisal!
Your post Swap Two Numbers With and Without Using Third Variable in Dart Programming was rewarded by CCS Curation Trail
“Home is where your heart is ❤️.”
👉 Join the CCS Curation Trail | Community Invitation
✅ Vote for visionaer3003 as witness