GO Program to print full Pyramid using *
Simple program in go language using for...... loop to print the Pyramid of *. Program first ask user to enter number of rows. Then output will be Pyramid of that rows.
Example
package main
import "fmt"
func main() {
var rows int
var k int = 0
fmt.Print("Enter number of rows :")
fmt.Scan(&rows)
for i := 1; i <= rows; i++ {
k=0
for space := 1; space <= rows-i; space++ {
fmt.Print(" ")
}
for {
fmt.Print("* ")
k++
if(k == 2*i-1){
break
}
}
fmt.Println("")
}
}
Most Helpful This Week
GO Program to Find Factorial of a Number
Program in Go language to Find Largest Element of an Array
Contains, ContainsAny, Count and EqualFold string functions in Go Language
GO Program to Swap Number Without Using Temporary Variables
GO Program to Find LCM and GCD of given two numbers
GO Program to Check Whether a Number is Palindrome or Not