Go Program to Print Mirrored Right Triangle Pattern

Write a Go Program to Print Mirrored Right Angled Triangle Star Pattern. In this Golang Mirrored Right Triangle example, the nested for loops iterates from start to end of rows. The if statement (if j <= rows-i) checks whether the column is less than or equals rows-i. If True, it prints empty space; otherwise, it print stars.

package main

import "fmt"

func main() {

    var i, j, rows int

    fmt.Print("Enter Rows for Mirrored Right Triangle = ")
    fmt.Scanln(&rows)

    fmt.Println("Mirrored Right Triangle Star Pattern")
    for i = 1; i <= rows; i++ {
        for j = 1; j <= rows; j++ {
            if j <= rows-i {
                fmt.Print(" ")
            } else {
                fmt.Print("*")
            }
        }
        fmt.Println()
    }
}
Go Program to Print Mirrored Right Triangle Pattern 1

This Golang program allows entering a string symbol and prints the Mirrored Right angled Triangle pattern of that symbol.

package main

import "fmt"

func main() {

    var i, j, rows int
    var ch string

    fmt.Print("Enter Rows for Mirrored Right Triangle = ")
    fmt.Scanln(&rows)

    fmt.Print("Enter Symbol for Mirrored Right Triangle = ")
    fmt.Scanln(&ch)

    fmt.Println("Mirrored Right Triangle Pattern")
    for i = 1; i <= rows; i++ {
        for j = 1; j <= rows; j++ {
            if j <= rows-i {
                fmt.Print(" ")
            } else {
                fmt.Printf("%s", ch)
            }
        }
        fmt.Println()
    }
}
Enter Rows for Mirrored Right Triangle = 10
Enter Symbol for Mirrored Right Triangle = $
Mirrored Right Triangle Pattern
         $
        $$
       $$$
      $$$$
     $$$$$
    $$$$$$
   $$$$$$$
  $$$$$$$$
 $$$$$$$$$
$$$$$$$$$$