Go Program to Print Downward Triangle Star Pattern

Write a Go program to print the downward triangle star pattern using for loop.

package main

import "fmt"

func main() {

	var i, j, row int

	fmt.Print("Enter Downward Triangle Star Pattern Rows = ")
	fmt.Scanln(&row)

	fmt.Println("**** Downward Triangle Star Pattern ****")

	for i = row - 1; i >= 0; i-- {
		for j = 0; j <= i; j++ {
			fmt.Printf("* ")
		}
		fmt.Println()
	}
}
Go Program to Print Downward Triangle Star Pattern

This Golang example prints the downward triangle pattern of a given character.

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {

	reader := bufio.NewReader(os.Stdin)

	var i, j, row int

	fmt.Print("Enter Downward Triangle Pattern Rows = ")
	fmt.Scanln(&row)

	fmt.Print("Enter Character to Print in Downward Triangle = ")
	ch, _, _ := reader.ReadRune()

	fmt.Println("**** Downward Triangle Pattern ****")

	for i = row - 1; i >= 0; i-- {
		for j = 0; j <= i; j++ {
			fmt.Printf("%c ", ch)
		}
		fmt.Println()
	}
}
Enter Downward Triangle Pattern Rows = 10
Enter Character to Print in Downward Triangle = $
**** Downward Triangle Pattern ****
$ $ $ $ $ $ $ $ $ $ 
$ $ $ $ $ $ $ $ $ 
$ $ $ $ $ $ $ $ 
$ $ $ $ $ $ $ 
$ $ $ $ $ $ 
$ $ $ $ $ 
$ $ $ $ 
$ $ $ 
$ $ 
$