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).
Golang Tutorial
Go, or Golang is a general purpose Programming language with a clean and simple syntax that avoids code complexity. Go has a collection of libraries, which are known to be the Go standard library. We can use these packages to perform most of the operations.
Most popular programming languages such as Java and C# do most things like writing code, building, debugging, and compiling are happening within their respective IDE’s. However, Go is a compiled language, and like any other, you have to use or work with command lines to run the program code. If you are a windows user, use the command prompt. And if you are a macOS user, use the Terminal.
Every Go program must have a main() function that acts as an entry point to the compiler.
Basic Go programs
The following are the basic and advanced Golang programs on Numbers and conditional statements.
- Golang Program to Print Hello World
- Go Program to add Two Numbers
- Go Program to Find the Compound Interest
- Go Program to Count Digits in a Number
- Go Program to Count Total Notes in an Amount
- Go Program to Find the Cube of a Number
- Go Program to Calculate the Employee Salary
- Go Program to calculate Electricity Bill
- Go Program to check Even or Odd
- Go Program to print Even Numbers from 1 to N
- Go Program to find Factors of a Number
- Go Program to find Factorial of a Number
- Go Program to find First Digit of a Number
- Go Program to find Generic Root of a Number
- Go Program to check Largest of Two Numbers
- Go Program to check Largest of Three Numbers
- Go Program to check Leap year
- Go Program to print Multiplication Table
- Go Program to print Natural Numbers from 1 to N
- Go Program to print Natural Numbers in Reverse Order
- Go Program to find NCR Factorial of a Number
- Go Program to find Number divisible by 5 and 11
- Go Program to print Odd Numbers 1 to N
- Go Program to find Product of Digits in a Number
- Check Palindrome Number
- Check Perfect Number
- Check Prime Number
- Check Positive or Negative
- Calculate Power of a Number
- Calculate Profit or Loss
- Print 1 to 100
- Print 1 to 100 without using loop
- Reverse a Number
- Roots of a Quadratic Equation
- Simple Interest
- Square of a Number
- Square root of a Number
- Sum and Average of Natural Numbers
- Sum of Digits in a Number
- Sum of Even Numbers
- Sum of Even and Odd Numbers
- Sum of Odd Numbers
- Swap Two Numbers
Go Array Program
The list of Golang programs on one dimensional Array.
- Add Two Arrays
- Arithmetic Operations on an Array
- Multiplication
- Calculate Array Average
- Count Duplicates in an Array
- Count Even and Odd Numbers in an Array
- Count Positive and Negative Numbers in an Array
- Largest Array Item
- Largest and Smallest Number in an Array
- Print Array Items
- Print Array Items in Even Index Position
- Print Array Items in Odd Index Position
- Print Even Numbers in an Array
- Print Negative Numbers in an Array
- Print Odd Numbers in an Array
- Print Positive Numbers in an Array
- Put Positive and Negatives in a Separate Array
- Reverse an Array
- Search for Array Items
- Smallest Array Item
- Sum of Array Items
Go Program on Matrix
These are some of the Matrix programs in Golang.
- Add Two Matrices
- Arithmetic Operations on Matrix
- Determinant of a Matrix
- Identity Matrix
- Interchange Matrix Diagonals
- Matrix Lower Triangle
- Matrix Multiplication
- Matrix Upper Triangle
- Print Matrix Items
- Scalar Matrix Multiplication
- Sparse Matrix
- Sum of Each Matrix Column
- Sum of Each Matrix Row
- Sum of Each Row and Column of a Matrix
- Sum of Matrix Diagonal
- Sum of Matrix Lower Triangle
- Sum of Matrix Opposite Diagonal
- Sum of Matrix Upper Triangle
- Symmetric Matrix
- Transpose a Matrix
- Check Two Matrixes are Equal
Go String Programs
The following are list of Golang programs to work with Strings.
- ASCII value of String Characters
- Concat Two String
- Convert Byte to String
- Convert String to Byte Array
- Find First Character in a String
- Find Last Character in a String
- Print String Characters
- String Length
Go Character Programs
In these Go example programs, we use both the Rune and the byte variables to represent the characters.
- Alphabet or Not
- ASCII Value of a Character
- Print ASCII Values of All Characters
- Check Character is a Lowercase
- Check Character is an Uppercase
- Convert Lowercase Character to Uppercase
- Convert Uppercase Character to Lowercase
- Check Digit or Not
- Print Alphabets from a to z
- Print Alphabets from A to Z
- 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.
- Golang Program to find Volume and Surface Area of a Cone
- Golang Program to find Volume and Surface Area of a Cube
- Golang Program to find Surface Area and Volume of a Cuboid
- Golang Program to find Volume and Surface Area of a Cylinder
- Golang Program to find Volume and Surface Area of a Sphere