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() } }
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
$
$ $
$ $ $
$ $ $ $
$ $ $ $ $
$ $ $ $ $ $
$ $ $ $ $ $ $
$ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $ $