Friday, August 2, 2019

Two-Dimensional Array Example in Go

A simple program to show you how to use two-dimensional array in golang programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com

Sample Program Output


Program Output

/* two_dimensional_one.go
   Author   : Mr. Jake Rodriguez Pomperada, MAED-IT
   Date     : August 2, 2019  Friday   7:37 AM
   Location : Bacolod City, Negros Occidental
   Website  : http://www.jakerpomperada.com
   Emails   : jakerpomperada@gmail.com and jake_pomperada@tup.edu.ph
 */
package main

import "fmt"

func main() {
fmt.Print("\n")
fmt.Print("\tTwo-Dimensional Array Example in Go")
fmt.Print("\n\n")
/* Two dimensional array declare and initilize */
var array_one = [3][2]int{{0, 1}, {1, 2}, {2, 3}}
// shorthand two dimensional array variable declaration
array_two := [2][2]int{{0, 1}, {1, 2}}
var i, j int
/* Iterating elements array one using for loop statement */
for i = 0; i < 3; i++ {
for j = 0; j < 2; j++ {
fmt.Printf("\tarray_one[%d][%d] = %d\n", i, j, array_one[i][j])
}
}
/* Iterating elements array two using for loop statement */
for i = 0; i < 2; i++ {
for j = 0; j < 2; j++ {
fmt.Printf("\tarray_two[%d][%d] = %d\n", i, j, array_two[i][j])
}
}
fmt.Print("\n")
fmt.Print("\tEnd of Program")
fmt.Print("\n")
}


No comments:

Post a Comment