GO Program to Swap Number Without Using Temporary Variables
In this program, user is asked to enter two numbers and program will swap two numbers without using third variable.
Example
package main
import "fmt"
func main(){
fmt.Print("Enter first number : ")
var first int
fmt.Scanln(&first)
fmt.Print("Enter second number : ")
var second int
fmt.Scanln(&second)
first = first-second
second = first+second
first = second-first
fmt.Println("First number :",first)
fmt.Println("Second number :",second)
}
Most Helpful This Week
Go program to find CNAME record of a domain
Golang program to print all Permutations of a given string
How do you handle HTTP requests in Go?
Unveiling the Potential of Quantum Computing in AI: A Game Changer for Industries
How do you handle HTTP client server logging in Go?
Make Your Retirement Luxurious with These 5 Game-Changing Altcoins