diff --git a/tests/hellogo/.gitignore b/tests/hellogo/.gitignore new file mode 100644 index 0000000..134cad0 --- /dev/null +++ b/tests/hellogo/.gitignore @@ -0,0 +1 @@ +hellogo diff --git a/tests/hellogo/Makefile b/tests/hellogo/Makefile new file mode 100644 index 0000000..4c36298 --- /dev/null +++ b/tests/hellogo/Makefile @@ -0,0 +1,10 @@ +.PHONY: all +all: hellogo + +hellogo: hellogo.go + go build -gcflags=all="-N -l" hellogo.go + +.PHONY: clean +clean: + rm -f hellogo + diff --git a/tests/hellogo/hellogo.go b/tests/hellogo/hellogo.go new file mode 100644 index 0000000..e9a0054 --- /dev/null +++ b/tests/hellogo/hellogo.go @@ -0,0 +1,29 @@ +package main + +import "fmt" + +type MyStruct struct { + x string + i int + f float64 +} + +func main() { + + fmt.Println("Hello, Go World!") + + x := "abc" + i := 3 + + fmt.Println(i) + fmt.Println(x) + + ms := &MyStruct{ + x: "cba", + i: 10, + f: 11.10335, + } + + fmt.Println(ms) +} + diff --git a/tests/hellogopyramid/.gitignore b/tests/hellogopyramid/.gitignore new file mode 100644 index 0000000..73a99fe --- /dev/null +++ b/tests/hellogopyramid/.gitignore @@ -0,0 +1 @@ +hellogopyramid diff --git a/tests/hellogopyramid/Makefile b/tests/hellogopyramid/Makefile new file mode 100644 index 0000000..66110c7 --- /dev/null +++ b/tests/hellogopyramid/Makefile @@ -0,0 +1,10 @@ +.PHONY: all +all: hellogopyramid + +hellogopyramid: hellogopyramid.go + go build -gcflags=all="-N -l" hellogopyramid.go + +.PHONY: clean +clean: + rm -f hellogopyramid + diff --git a/tests/hellogopyramid/hellogopyramid.go b/tests/hellogopyramid/hellogopyramid.go new file mode 100644 index 0000000..0d38415 --- /dev/null +++ b/tests/hellogopyramid/hellogopyramid.go @@ -0,0 +1,47 @@ +// Program in Golang to print Pyramid of Numbers + +package main + +import "fmt" + +func main () { + + var rows,k,temp,temp1 int + + fmt.Print("Enter number of rows : ") + fmt.Scan(&rows) + + for i := 1; i <= rows; i++ { + + for j := 1; j <= rows-i; j++ { + fmt.Print(" ") + temp++ + } + + for { + + if ( temp <= rows-1) { + fmt.Printf(" %d", i+k) + temp++ + }else{ + temp1++ + fmt.Printf(" %d", (i+k-2*temp1)) + } + + k++ + + if (k == 2*i-1) { + break + } + + } + + temp = 0 + temp1 = 0 + k = 0 + + fmt.Println("") + } + +} +