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.

Read Also:  Laravel GroupBy Error Solution 5.5 , 5.6, 5.7

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.

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.

Read Also:  Simple Hello World Example using Angular

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:

simple Program in Golang to print Pyramid of Numbers Results:

Read Also:  URL Redirect in Laravel Tutorial

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.


Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  GO Program to Display Fibonacci Sequence
  2. Read Also:  Golang to Find the GCD and LCM of Two Integers
  3. Read Also:  Table with CSS Styles using Angular Example
  4. Read Also:  php check if string contains exist or not
  5. Read Also:  Event Directives with Parameters using Angular Example
  6. Read Also:  How to Fetch data from an External JSON in AngularJS
  7. Read Also:  Update Query In Codeigniter Example Tutorial
  8. Read Also:  Bash if else statement using Bash Scripting
  9. Read Also:  Laravel Aggregate Object and Debugging eloquent methods
  10. Read Also:  Check Armstrong Number in GO Program
CLOSEX