Program in Go language to print Floyd's Triangle
Simple program using Print, Printf and Println statements to print Floyd's Triangle up to N number of rows entered by user.
Example
// Golang Program to Print Floyd's Triangle.
package main
import "fmt"
func main(){
var rows int
var temp int = 1
fmt.Print("Enter number of rows : ")
fmt.Scan(&rows)
for i := 1; i <= rows; i++ {
for k := 1; k <= i; k++ {
fmt.Printf(" %d",temp)
temp++
}
fmt.Println("")
}
}
Output
Enter number of rows : 5
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
Most Helpful This Week
What is an HTTP server in Go?
Sierpinski Carpet in Go Programming Language
Golang program for implementation of Tower of Hanoi Algorithm
How to Improve the Performance of Your Golang Application?
Illustration of Cigarette Smokers Problem in Golang
Golang read file line by line to string
Golang program for implementation of Median of Medians
Comparing Structs with the Different Values Assigned to Data Fields
Program in Golang to print Pyramid of Numbers
Web Application to Get Trending Hashtags Near a Location