Go Program to Print Pyramid Pattern using numbers

Today, We want to share with you Go Program to Print Pyramid Pattern using numbers.In this post we will show you Golang Number Pyramid Program, hear for diamond pattern programs in Go we will give you demo and example for implement.In this post, we will learn about Golang for loop – Exercises, Practice, Solution with an example.

Go Program to Print Pyramid Pattern using numbers

There are the Following The simple About Go Program to Print Pyramid Pattern using numbers Full Information With Example and source code.

As I will cover this Post with live Working example to develop alphabet pattern programs in Go, so the Golang Number Pyramid Program for this example is following below.

Also Read This πŸ‘‰   Check Armstrong Number in GO Program
Pattern programs in GO Example

Simple easy Pattern programs in GO Example using for…… loop to display the Pyramid of numbers. Example first ask any user to enter number of total rows. after that display results will be Pyramid type of that rows.

Free Live Chat for Any Issue

Program in Golang to print Pyramid of Numbers

package main
import "fmt"
 
func main() {
    var total_rows,k,first_tmp_val,second_tmp int
    fmt.Print("Enter number of total_rows :")
    fmt.Scan(&total_rows)
 
    for i := 1; i <= total_rows; i++ {
         
        for j := 1; j <= total_rows-i; j++ {
            fmt.Print("  ")
            first_tmp_val++
        }
        for{
            if( first_tmp_val <= total_rows-1){
                fmt.Printf(" %d",i+k)
                first_tmp_val++
            }else{
                second_tmp++
                fmt.Printf(" %d",(i+k-2*second_tmp))
            }
            k++
 
            if(k == 2*i-1){             
                break
            }
 
        }
        first_tmp_val = 0
        second_tmp = 0
        k = 0
        fmt.Println("")
    }
 
}
 

Output of above Go program:

Also Read This πŸ‘‰   Laravel 6 tree view Plugins using jQuery Example

simple Program in Golang to print Pyramid of Numbers Results:

Enter number of total_rows : 5
         1 
       2 3 2
     3 4 5 4 3
   4 5 6 7 6 5 4
 5 6 7 8 9 8 7 6 5

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Go Program to Print Pyramid Pattern using numbers.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Rate this post