Write a Go program to print the inverted mirrored right angled triangle star pattern using for loop.
package main import "fmt" func main() { var i, j, k, row int fmt.Print("Enter Inverted Mirrored Right Triangle Star row = ") fmt.Scanln(&row) fmt.Println("Inverted Mirrored Right Triangle Star Pattern") for i = row; i > 0; i-- { for j = row - i; j > 0; j-- { fmt.Printf(" ") } for k = 0; k < i; k++ { fmt.Printf("* ") } fmt.Println() } }
This Go example prints the mirrored inverted right angled triangle pattern of a given character.
package main import ( "bufio" "fmt" "os" ) func main() { reader := bufio.NewReader(os.Stdin) var i, j, k, row int fmt.Print("Enter Inverted Mirrored Right Triangle Star row = ") fmt.Scanln(&row) fmt.Print("Character to Print Inverted Mirrored Right Triangle = ") ch, _, _ := reader.ReadRune() fmt.Println("Inverted Mirrored Right Triangle Star Pattern") for i = row; i > 0; i-- { for j = row - i; j > 0; j-- { fmt.Printf(" ") } for k = 0; k < i; k++ { fmt.Printf("%c ", ch) } fmt.Println() } }
Enter Inverted Mirrored Right Triangle Star row = 15
Character to Print Inverted Mirrored Right Triangle = $
Inverted Mirrored Right Triangle Star Pattern
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $
$ $ $ $ $ $ $
$ $ $ $ $ $
$ $ $ $ $
$ $ $ $
$ $ $
$ $
$