Showing posts with label Bubble Sort Program in Go. Show all posts
Showing posts with label Bubble Sort Program in Go. Show all posts

Friday, August 2, 2019

Bubble Sort Program in Go


Write a program using a one-dimensional array to implement a bubble sort algorithm. The program will ask the user how many items to be processed and then the program will display the original arrangement of the numbers and then display the sorted arrangement of the numbers on the screen.

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 Listing

/* bubble_sort.go
   Author   : Mr. Jake Rodriguez Pomperada, MAED-IT
   Date     : August 1, 2019  Thursday  9:54 PM
   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() {
{
var items[50] int
num_input := 0
a := 0
b := 0
temp := 0

fmt.Print("\n")
fmt.Print("\t\tBubble Sort Program in Go")
fmt.Print("\n\n")
fmt.Print("\tGive the size of array: ");
fmt.Scanln(&num_input)
fmt.Print("\n");
for a = 0; a < num_input; a++ {
fmt.Printf("\tEnter array element value in item no. %d : ",a+1);
fmt.Scanln(&items[a])
}
fmt.Print("\n");
fmt.Println("\tOriginal Array Arrangement");
fmt.Print("\n");
for a = 0; a < num_input; a++ {
fmt.Printf("\t%d ", items[a])
}
for a = 1; a < num_input; a++ {
for b = 0; b < (num_input - a); b++ {
if (items[b] > items[b+1]) {
temp = items[b]
items[b] = items[b+1]
items[b+1] = temp
}
}
}
fmt.Print("\n\n");
fmt.Println("\tSorted Array Arrangement");
fmt.Print("\n");
for a = 0; a < num_input; a++ {
fmt.Printf("\t%d ", items[a])
}
fmt.Print("\n\n")
fmt.Print("\tEnd of Program")
fmt.Print("\n")
}
}