Go Programs

The following is the list of Go programming examples or Go programs that help you practice at your lab. We categorically divided this page into different sections, and each section has a different set of Go programs.

All the Go programs that we mentioned here have the program code along with the execution result. However, we haven’t explained the step-wise analysis because we already did in C programs and Python Programs. To make it simple, we have given the same names to these Go examples. I suggest you refer to C or Python programs to understand the analysis part (if needed).

Basic Go programs

The following are the basic and advanced Golang programs on Numbers and conditional statements.

  1. Golang Program to Print Hello World
  2. Go Program to add Two Numbers
  3. Go Program to Find the Compound Interest
  4. Go Program to Count Digits in a Number
  5. Go Program to Count Total Notes in an Amount
  6. Go Program to Find the Cube of a Number
  7. Go Program to Calculate the Employee Salary
  8. Go Program to calculate Electricity Bill
  9. Go Program to check Even or Odd
  10. Go Program to print Even Numbers from 1 to N
  11. Go Program to find Factors of a Number
  12. Go Program to find Factorial of a Number
  13. Go Program to find First Digit of a Number
  14. Go Program to find Generic Root of a Number
  15. Go Program to check Largest of Two Numbers
  16. Go Program to check Largest of Three Numbers
  17. Go Program to check Leap year
  18. Go Program to print Multiplication Table
  19. Go Program to print Natural Numbers from 1 to N
  20. Go Program to print Natural Numbers in Reverse Order
  21. Go Program to find NCR Factorial of a Number
  22. Go Program to find Number divisible by 5 and 11
  23. Go Program to print Odd Numbers 1 to N
  24. Go Program to find Product of Digits in a Number
  25. Check Palindrome Number
  26. Check Perfect Number
  27. Check Prime Number
  28. Check Positive or Negative
  29. Calculate Power of a Number
  30. Calculate Profit or Loss
  31. Print 1 to 100
  32. Print 1 to 100 without using loop
  33. Reverse a Number
  34. Roots of a Quadratic Equation
  35. Simple Interest
  36. Square of a Number
  37. Square root of a Number
  38. Sum and Average of Natural Numbers
  39. Sum of Digits in a Number
  40. Sum of Even Numbers
  41. Sum of Even and Odd Numbers
  42. Sum of Odd Numbers
  43. Swap Two Numbers

Go Array Program

The list of Golang programs on one dimensional Array.

  1. Add Two Arrays
  2. Arithmetic Operations on an Array
  3. Multiplication
  4. Calculate Array Average
  5. Count Duplicates in an Array
  6. Count Even and Odd Numbers in an Array
  7. Count Positive and Negative Numbers in an Array
  8. Largest Array Item
  9. Largest and Smallest Number in an Array
  10. Print Array Items
  11. Print Array Items in Even Index Position
  12. Print Array Items in Odd Index Position
  13. Print Even Numbers in an Array
  14. Print Negative Numbers in an Array
  15. Print Odd Numbers in an Array
  16. Print Positive Numbers in an Array
  17. Put Positive and Negatives in a Separate Array
  18. Reverse an Array
  19. Search for Array Items
  20. Smallest Array Item
  21. Sum of Array Items

Go Program on Matrix

These are some of the Matrix programs in Golang.

  1. Add Two Matrices
  2. Arithmetic Operations on Matrix
  3. Determinant of a Matrix
  4. Identity Matrix
  5. Interchange Matrix Diagonals
  6. Matrix Lower Triangle
  7. Matrix Multiplication
  8. Matrix Upper Triangle
  9. Print Matrix Items
  10. Scalar Matrix Multiplication
  11. Sparse Matrix
  12. Sum of Each Matrix Column
  13. Sum of Each Matrix Row
  14. Sum of Each Row and Column of a Matrix
  15. Sum of Matrix Diagonal
  16. Sum of Matrix Lower Triangle
  17. Sum of Matrix Opposite Diagonal
  18. Sum of Matrix Upper Triangle
  19. Symmetric Matrix
  20. Transpose a Matrix
  21. Check Two Matrixes are Equal

Go String Programs

The following are list of Golang programs to work with Strings.

  1. ASCII value of String Characters
  2. Concat Two String
  3. Convert Byte to String
  4. Convert String to Byte Array
  5. Find First Character in a String
  6. Find Last Character in a String
  7. Print String Characters
  8. String Length

Go Character Programs

In these Go example programs, we use both the Rune and the byte variables to represent the characters.

  1. Alphabet or Not
  2. ASCII Value of a Character
  3. Print ASCII Values of All Characters
  4. Check Character is a Lowercase
  5. Check Character is an Uppercase
  6. Convert Lowercase Character to Uppercase
  7. Convert Uppercase Character to Lowercase
  8. Check Digit or Not
  9. Print Alphabets from a to z
  10. Print Alphabets from A to Z
  11. Check Vowel or Consonant

Golang Volume and Surface Area Programs

The following Go examples will find and return the volume, surface area, and lateral surface area of different shapes.

  1. Golang Program to find Volume and Surface Area of a Cone
  2. Golang Program to find Volume and Surface Area of a Cube
  3. Golang Program to find Surface Area and Volume of a Cuboid
  4. Golang Program to find Volume and Surface Area of a Cylinder
  5. Golang Program to find Volume and Surface Area of a Sphere

Go Number Pattern Programs

  1. Box Number Pattern of 1 and 0
  2. Hollow Box Number Pattern
  3. 1 and 0 in Alternative Columns
  4. 1 and 0 in Alternative Rows
  5. Diamond Number Pattern
  6. Floyd’s Triangle
  7. K Shape Number Pattern
  8. Left Pascals Number Triangle
  9. Rectangle Number Pattern
  10. Right Angled Triangle Number Pattern
  11. Right Angled Triangle of 1 and 0
  12. Right Angled Triangle of Consecutive Column Numbers
  13. Right Angled Triangle of Consecutive Rows Numbers
  14. Right Angled Triangle of Incremented Numbers
  15. Right Angled Triangle of Numbers in Reverse
  16. Right Angled Triangle of Same Column Numbers
  17. Inverted Right Triangle Number Pattern
  18. Inverted Right Triangle of Column Numbers in Reverse
  19. Inverted Right Triangle of Consecutive Column Numbers
  20. Inverted Right Triangle of Descending Order Numbers
  21. Inverted Right Triangle of Same Column Numbers
  22. Pascal Triangle
  23. Right Pascals Number Triangle
  24. Right Arrow Number Pattern
  25. Square Number Pattern
  26. Same Numbers on all Sides of a Square
  27. Same Numbers in Square Rows and Columns
  28. Simple Number Pattern
  29. Sandglass Number Pattern

Go Star and Alphabets Pattern Programs

  1. Diamond Star Pattern
  2. Hollow Diamond Star Pattern
  3. Hollow Diamond inside a Square Star Pattern
  4. Right Half Diamond Star Pattern
  5. Mirrored Half Diamond Star Pattern
  6. Downward Triangle Star Pattern
  7. Exponentially Increased Star Pattern
  8. Inverted Pyramid Star Pattern
  9. Inverted Right Triangle Star Pattern
  10. Hollow Inverted Right Triangle Star Pattern
  11. Reverse Mirrored Right Triangle Star Pattern
  12. Pyramid Star Pattern
  13. Hollow Star Pyramid Pattern
  14. Hollow Inverted Star Pyramid Pattern
  15. Left Pascals Star Triangle
  16. Hollow Left Pascals Star Triangle
  17. Right Pascals Star Triangle
  18. Hollow Right Pascals Star Triangle
  19. Rectangle Star Pattern
  20. Hollow Rectangle Star Pattern
  21. Rhombus Star Pattern
  22. Hollow Rhombus Star Pattern
  23. Mirrored Rhombus Star Pattern
  24. Hollow Mirrored Rhombus Star Pattern
  25. Hollow Right Angled Triangle Star Pattern
  26. Mirrored Right Angled Triangle Pattern
  27. Inverted Mirrored Right Angled Triangle Star Pattern
  28. Reversed Mirrored Right Angled Triangle Pattern
  29. Left Arrow Star Pattern
  30. Right Arrow Star Pattern
  31. Right Angled Triangle Star Pattern
  32. Square Star Pattern
  33. Hollow Square Star Pattern
  34. Hollow Square with Diagonals Star Pattern
  35. Sandglass Star Pattern
  36. Plus Star Pattern
  37. X Star Pattern
  38. K Shape Alphabets Pattern
  39. Repeated Characters Pattern
  40. Right Triangle Alphabets Pattern
  41. Triangle Alphabets Pattern