Go program to Print Sandglass Number Pattern

Write a Go program to print the sandglass number pattern using for loop.

package main

import "fmt"

func main() {

	var i, j, k, row int

	fmt.Print("Enter Sandglass Number Pattern Rows = ")
	fmt.Scanln(&row)

	fmt.Println("**** Sandglass Number Pattern ****")

	for i = 1; i <= row; i++ {
		for j = 1; j < i; j++ {
			fmt.Printf(" ")
		}
		for k = i; k <= row; k++ {
			fmt.Printf("%d ", k)
		}
		fmt.Println()
	}

	for i = row - 1; i >= 1; i-- {
		for j = 1; j < i; j++ {
			fmt.Printf(" ")
		}
		for k = i; k <= row; k++ {
			fmt.Printf("%d ", k)
		}
		fmt.Println()
	}
}
Go program to Print Sandglass Number Pattern

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.