Go language program to take two numbers from user and add those two numbers


Following program shows you how to take two numbers from user and add those two numbers.
In this program we take two numbers from user using fmt.Scanf() method and add those two numbers

package main

import "fmt"

func main() {

  var input1 int
  var input2 int
  var result int
  fmt.Println("Enter first number:")
  fmt.Scanf("%d", &input1)
  fmt.Println("Enter second number:")
  fmt.Scanf("%d", &input2)
  result = input1 + input2
  fmt.Println("Sum of the given two numbers is: " , result)
}

Output:

Enter first number:
 25
Enter second number:
 28
Sum of the given two numbers is:  53