Go Program to Print Right Angled Triangle Star Pattern

Write a Go Program to Print Right angled Triangle Star Pattern. In this Golang Right Angled Triangle Star example, the first for loop (for i = 1; i <= rows; i++) iterates from start to end. The second for loop (for j = 1; j <= i; j++) begins iteration from 1 to goes up to i and print stars.

package main

import "fmt"

func main() {

    var i, j, rows int

    fmt.Print("Rows to Print the Right Angled Triangle = ")
    fmt.Scanln(&rows)

    fmt.Println("\nRight Angled Triangle Star Pattern")
    for i = 1; i <= rows; i++ {
        for j = 1; j <= i; j++ {
            fmt.Print("* ")
        }
        fmt.Println()
    }
}
Go Program to Print Right Angled Triangle Star Pattern 1

This Golang program allows inserting any symbol and prints that symbol in the Right angled Triangle pattern.

package main

import "fmt"

func main() {

    var i, j, rows int
    var sym string

    fmt.Print("Rows to Print the Right Angled Triangle = ")
    fmt.Scanln(&rows)

    fmt.Print("Symbol to Print as Right Angled Triangle = ")
    fmt.Scanln(&sym)

    fmt.Println("\nRight Angled Triangle of Given Symbol")
    for i = 1; i <= rows; i++ {
        for j = 1; j <= i; j++ {
            fmt.Printf("%s ", sym)
        }
        fmt.Println()
    }
}
Rows to Print the Right Angled Triangle = 11
Symbol to Print as Right Angled Triangle = $

Right Angled Triangle of Given Symbol
$ 
$ $ 
$ $ $ 
$ $ $ $ 
$ $ $ $ $ 
$ $ $ $ $ $ 
$ $ $ $ $ $ $ 
$ $ $ $ $ $ $ $ 
$ $ $ $ $ $ $ $ $ 
$ $ $ $ $ $ $ $ $ $ 
$ $ $ $ $ $ $ $ $ $ $ 

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.