diff --git a/Lec13/go.mod b/Lec13/go.mod new file mode 100644 index 0000000..a692304 --- /dev/null +++ b/Lec13/go.mod @@ -0,0 +1,3 @@ +module main.go + +go 1.24.4 diff --git a/Lec13/main.go b/Lec13/main.go new file mode 100644 index 0000000..8a89758 --- /dev/null +++ b/Lec13/main.go @@ -0,0 +1,18 @@ +package main + +import "fmt" + +func main() { + command := "addition" + res := retFunc(command) + fmt.Println("Result is ",res(10,30)) + fmt.Println("Type is %T",res) +} + +func retFunc (a string) func(a,b int) int { + if a == "addition" { + return func(a,b int) int {return a + b} + } else { + return func(a,b int) int {return a - b} + } +} diff --git a/Lec14/go.mod b/Lec14/go.mod new file mode 100644 index 0000000..a692304 --- /dev/null +++ b/Lec14/go.mod @@ -0,0 +1,3 @@ +module main.go + +go 1.24.4 diff --git a/Lec14/main.go b/Lec14/main.go new file mode 100644 index 0000000..ff91262 --- /dev/null +++ b/Lec14/main.go @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "strconv" +) + +const ( + A = 10 + B = 11 +) + +func main() { + + var constInt8 int8 = A + var constString string = strconv.Itoa(A) + + fmt.Println("constInt8 is ",constInt8) + fmt.Println("constString is ",constString) + +} + +func checkConst() { + if A == 10 { + fmt.Printf("a is 10\n") + } +} diff --git a/Lec15/go.mod b/Lec15/go.mod new file mode 100644 index 0000000..a692304 --- /dev/null +++ b/Lec15/go.mod @@ -0,0 +1,3 @@ +module main.go + +go 1.24.4 diff --git a/Lec15/main.go b/Lec15/main.go new file mode 100644 index 0000000..246a5ec --- /dev/null +++ b/Lec15/main.go @@ -0,0 +1,41 @@ +package main + +import "fmt" + +func main() { + // var variable int = 30 + // var pointer *int = &variable + + // fmt.Printf("Type of pointer %T\n",pointer) + // fmt.Printf("Value of pointer %v\n",pointer) + + // secondPtr := &pointer + // fmt.Println("Pointer to pointer",secondPtr) + + + // zeroPtr := new(int) + // *zeroPtr += 40 + // fmt.Println("Address is ",*zeroPtr) + + + // a := 10 + // c := a + // b := &a + // *b += 2 + + // c++ + // fmt.Printf("Val of A is %d and val of C is %d\n",a, c) + // fmt.Printf("Val of A after changing ref is %d",a) + + sample := 1 + // samplePtr := &sample + fmt.Println("Sample val is",sample) + kek(sample) + fmt.Println("Sample val is",sample) + +} + +func kek(val int) { + fmt.Println("Val of val is",val) + val += 100 +} \ No newline at end of file diff --git a/Lec16/go.mod b/Lec16/go.mod new file mode 100644 index 0000000..a692304 --- /dev/null +++ b/Lec16/go.mod @@ -0,0 +1,3 @@ +module main.go + +go 1.24.4 diff --git a/Lec16/main.go b/Lec16/main.go new file mode 100644 index 0000000..75b7283 --- /dev/null +++ b/Lec16/main.go @@ -0,0 +1,15 @@ +package main + +import "fmt" + +func main() { + arr := [3]int{1,2,3} + fmt.Println("Initial array is ", arr) + mutation(&arr) + fmt.Println("Modified array is ", arr) +} + +func mutation(arr *[3]int) { + (*arr)[0] = 900 + (*arr)[2] = 1000 +} \ No newline at end of file diff --git a/Lec17/go.mod b/Lec17/go.mod new file mode 100644 index 0000000..a692304 --- /dev/null +++ b/Lec17/go.mod @@ -0,0 +1,3 @@ +module main.go + +go 1.24.4 diff --git a/Lec17/main.go b/Lec17/main.go new file mode 100644 index 0000000..13209d3 --- /dev/null +++ b/Lec17/main.go @@ -0,0 +1,3 @@ +package main + +func main() { }