Functions
// Importing the "fmt" package, which provides functions for formatted I/O.
import "fmt"
// Function plus takes two integers (a and b) as parameters and returns their sum.
func plus(a int, b int) int {
return a + b
}
// Function plusPlus takes three integers (a, b, and c) as parameters and returns their sum.
func plusPlus(a, b, c int) int {
return a + b + c
}
// The main function, which serves as the entry point for the program.
func main() {
// Calling the plus function with arguments 1 and 2, storing the result in the variable "res".
res := plus(1, 2)
// Printing the result of the addition operation.
fmt.Println("1+2 =", res)
// Calling the plusPlus function with arguments 1, 2, and 3, storing the result in the variable "res".
res = plusPlus(1, 2, 3)
// Printing the result of the addition operation.
fmt.Println("1+2+3 =", res)
}Output
Last updated