go program(2)
go program(2)
package main
import (
"fmt"
"strings"
)
func main() {
// String Comparison
CompareStrings("Hello", "World") // -1
CompareStrings("World", "Hello") // 1 (Fixed this line)
CompareStrings("Hello", "Hello") // 0
// String Replace
ReplaceString("Fall", "a", "e")
// String Join
words := []string{"I", "love", "Golang"}
JoinStrings(words) // "I love Golang"
// String Split
SplitString("I Love Golang") // ["I", "Love", "Golang"]
}
import (
"fmt"
)
// Employee struct to store employee information
type Employee struct {
ID int
Name string
Department string
BasicSalary float64
HRA float64
PF float64
ESI float64
OtherDeductions float64
}
func main() {
// Create some sample employees
employees := []Employee{
{ID: 1, Name: "John Doe", Department: "IT", BasicSalary: 50000, HRA: 20000, PF:
6000, ESI: 1000, OtherDeductions: 0},
{ID: 2, Name: "Jane Smith", Department: "HR", BasicSalary: 60000, HRA: 25000, PF:
7200, ESI: 1200, OtherDeductions: 0},
}
package main
import "fmt"
func main() {
var num int
var num1 int
var res int
var ptr *int
num = 22
fmt.Println("Addre0073s of num:",&num)
fmt.Println("Value of num:",num)
ptr = &num
fmt.Println("\nAddress of pointer ptr:",ptr)
fmt.Println("Content of pointer ptr:",*ptr)
num1 = 11
fmt.Println("\nAddress of pointer ptr:",ptr)
fmt.Println("Content of pointer ptr:",*ptr)
*ptr = 2
fmt.Println("\nAddress of num:",&num)
fmt.Println("Value of num:",num)
res=num+num1
fmt.Println("Addition of Two value",res)
Output
Address of num: 0xc0000120b0
Value of num: 22