GO Program to take user input and addition of two strings
In this program, user is asked to enter two string. The use of Print function and addition of two strings without storing value in variable.
Example
package main
import "fmt"
func main() {
fmt.Print("Enter First String: ") //Print function is used to display output in same line
var first string
fmt.Scanln(&first) // Take input from user
fmt.Print("Enter Second String: ")
var second string
fmt.Scanln(&second)
fmt.Print(first + second) // Addition of two string
}
what to do based on the types of the arguments. Because both sides of the + are strings, the compiler assumes you mean concatenation and not addition (addition is meaningless for strings).
Most Helpful This Week
Interfaces with similar methods in Go Programming Language
Invalid operation: <variable> (type <type>) does not support indexing error in Golang
Panic: runtime error: index out of range error in Golang
Syntax error: unexpected <token> error in Golang
How do you handle HTTP server caching in Go?
Cannot call non-function <variable> error in Golang