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

Run it Now
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("\nSum is:", s)
}

Output:

Enter two numbers:3 4
Sum is: 7