Go Program to find the sum of two numbers using Scan()


In this program, you will learn how to find the sum of two numbers using a Scan() function in Go.


20 = 10 + 10

30 = 10 + 20

Example: How to find the sum of two numbers using a Scan() function in Go

package main
import "fmt"

func main() {
	var a, b, s int
	fmt.Print("Enter two numbers:")
	fmt.Scan(&a, &b)
	s = a + b
	fmt.Println("Sum is:", s)
}

Output:

Enter two numbers:10 20
Sum is: 30