{"id":8475,"date":"2023-01-03T23:00:00","date_gmt":"2023-01-03T17:30:00","guid":{"rendered":"https:\/\/www.codingbroz.com\/?p=8475"},"modified":"2023-01-03T15:34:20","modified_gmt":"2023-01-03T10:04:20","slug":"go-program-to-swap-two-numbers","status":"publish","type":"post","link":"https:\/\/www.codingbroz.com\/go-program-to-swap-two-numbers\/","title":{"rendered":"Go Program to Swap Two Numbers"},"content":{"rendered":"\n

In this post, we will learn how to write a program to swap two numbers using the Go programming language<\/strong>.<\/p>\n\n\n\n

This program asks the user to enter two integers and then stores the values of those two integers in two different variables. After that, we use a third variable to swap the values of the two variables.<\/p>\n\n\n\n

Suppose the first integer entered by the user is 7<\/strong>, and the second integer is 91<\/strong>. Then, before swapping, the variable “a”<\/strong> contained the value of 7<\/strong> and the variable “b”<\/strong> contained the value of “91.\u201d<\/strong><\/p>\n\n\n\n

But after the swapping process, the values will be interchanged. In that case, variable “a”<\/strong> will contain the integer “91,”<\/strong> whereas variable “b”<\/strong> will contain the integer “7.\u201d<\/strong><\/p>\n\n\n\n

Before Swapping:- \nFirst number =  7\nSecond number =  91\nAfter Swapping:- \nFirst number =  91\nSecond number =  7<\/code><\/pre>\n\n\n\n

So, without further ado, let\u2019s begin this tutorial.<\/p>\n\n\n\n

\n