Go Program to Print Rectangle Star Pattern

Write a Go Program to Print Rectangle Star Pattern. In this Golang Rectangle Star pattern example, the nested for loop iterates rectangle rows and columns and print stars.

package main

import "fmt"

func main() {

    var i, j, row, col int

    fmt.Print("Enter the Rectangle Rows = ")
    fmt.Scanln(&row)

    fmt.Print("Enter the Rectangle Columns = ")
    fmt.Scanln(&col)

    fmt.Println("Rectangle Star Pattern")
    for i = 0; i < row; i++ {
        for j = 0; j < col; j++ {
            fmt.Print("* ")
        }
        fmt.Println()
    }
}
Go Program to Print Rectangle Star Pattern 1

This Golang program allows entering any Symbol and prints the Rectangle pattern of that symbol.

package main

import "fmt"

func main() {

    var i, j, row, col int
    var sym string

    fmt.Print("Enter the Rectangle Rows = ")
    fmt.Scanln(&row)

    fmt.Print("Enter the Rectangle Columns = ")
    fmt.Scanln(&col)

    fmt.Print("Symbol to Print as Rectangle = ")
    fmt.Scanln(&sym)

    fmt.Println("Rectangle Pattern")
    for i = 0; i < row; i++ {
        for j = 0; j < col; j++ {
            fmt.Printf("%s ", sym)
        }
        fmt.Println()
    }
}
Enter the Rectangle Rows = 7
Enter the Rectangle Columns = 20
Symbol to Print as Rectangle = $
Rectangle Pattern
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ 
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ 
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ 
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ 
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ 
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ 
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $