Akhil Sharma

Akhil Sharma

507 Articles Published

Articles by Akhil Sharma

Page 4 of 51

Golang program to take in a slice of integers and compute their sum using concurrency

Akhil Sharma
Akhil Sharma
Updated on 04-Aug-2023 1K+ Views

In this Go language article, we will write programs to take in a slice of integers and compute their sum using concurrency. Concurrency helps multiple tasks or operations to be performed simultaneously. It helps make efficient use of system resources. It is achieved using Go routines which are light-weight threads and channels which helps in the communication between the go routines. Syntax func make ([] type, size, capacity) The make function in go language is used to create an array/map it accepts the type of variable to be created, its size and capacity as arguments. func range(variable) The ...

Read More

Golang program to sort a slice of integers using merge sort with concurrency

Akhil Sharma
Akhil Sharma
Updated on 04-Aug-2023 369 Views

In this article, we will write Go language programs to sort a slice of integers using merge sort with concurrency. It is a process which makes the parts of a program run independently and parallelly enhancing the efficiency of the program. Go routines and channels are used to execute concurrency. Merge sort is a divide and conquer algorithm used to sort the unsorted array or slice by dividing the input slice into smaller sub-slices, individually sort them recursively and then merge them into a single slice which is sorted. Syntax func make ([] type, size, capacity) The make function ...

Read More

Golang program to compute the factorial of a number using concurrency

Akhil Sharma
Akhil Sharma
Updated on 04-Aug-2023 605 Views

In this article, we will write Go language programs to compute the factorial of a number using concurrency. It is a task of implementing multiple operations simultaneously and can be implemented using Go routines and channels. Go routines are the lightweight threads and channels help in non-conflicting communications between the routines. Syntax func make ([] type, size, capacity) The make function in go language is used to create an array/map it accepts the type of variable to be created, its size and capacity as arguments. Algorithm This program imports the necessary packages main and fmt. In this ...

Read More

Golang program to compute all prime numbers up to a given number using concurrency

Akhil Sharma
Akhil Sharma
Updated on 04-Aug-2023 631 Views

In this Go language article, we will write programs to compute all prime numbers up to a given number using concurrent execution. Concurrent execution is the process of executing multiple tasks simultaneously. In Golang, go routines and channels are used to create concurrent programs. Go routines are lightweight threads which are managed by the Go runtime and channels help in the communication between Go routines without any conflicts. Syntax func make ([] type, size, capacity) The make function in go language is used to create an array/map it accepts the type of variable to be created, its size ...

Read More

Golang program to return the nth number in fibonacci sequence using dynamic programming

Akhil Sharma
Akhil Sharma
Updated on 04-Aug-2023 2K+ Views

In this article, we will write Go language programs to return the nth number in Fibonacci sequence using dynamic programming. It is a technique used to solve complex problems by breaking them into smaller sub problems. Memoization is the process of storing the output of the function calls in some data structure by which the next time call is made it need not calculate the output again, it can use that value to make the computation which in return lessens the execution time. Syntax func make ([] type, size, capacity) The make function in go language is used to ...

Read More

Golang program to calculate the symmetric difference between two slices

Akhil Sharma
Akhil Sharma
Updated on 24-Jul-2023 616 Views

Slice is similar to an array, the only difference is that an array is a fixed sequence of elements whereas slice the array elements are dynamic. This makes the slice more efficient and faster in various applications. In the slice, the elements are passed by reference instead of values. In this article, we are going to learn about different techniques to calculate the symmetric difference between two slice using Golang programming. Algorithm Step 1 − Create a package main and declare fmt(format package) package in the program where main produces executable codes and fmt helps in formatting input and ...

Read More

Golang Program to Creates Two Channels, One For Even Numbers And Another For Odd Numbers

Akhil Sharma
Akhil Sharma
Updated on 20-Jul-2023 2K+ Views

In this article, we'll make two channels in Go: one for even numbers and another for odd numbers. We are going to send the even numbers to the even channel and the odd numbers to the odd channel.Here we are going to use two different methods: using creating even and odd channels and Sending Even and Odd Numbers to Channels  along with examples to elaborate the concept. Syntax close(evenChan) This is a built in function call used to close a channel. This make sure that no more value will be sent on the channel, and a send operation on ...

Read More

Golang Program to Creates a Buffered Channel of Size 5 And Sends 10 Integers to The Channel Using a Loop

Akhil Sharma
Akhil Sharma
Updated on 20-Jul-2023 217 Views

In this article, we focus on making a buffered channel of size 5 and sending 10 integers to the channel using a loop. The program illustrates how to make and utilize a buffered channel to send large values.Here we are going to use two different methods: by Sending integers to the channel using a loop and by creating a buffered channel along with examples to elaborate the concept. Syntax ch := make(chan int, bufferSize) The Syntax ch := make(chan int, bufferSize) creates a buffered channel ch of type int with a specified buffer size, allowing the sender to send ...

Read More

Golang Program to Get Details About the Car Using Its Number Plate and Engine Number

Akhil Sharma
Akhil Sharma
Updated on 20-Jul-2023 199 Views

In this article, the Golang program is designed to recover details of  a car utilizing its number plate and engine number. It allows users to input the car's data and bring important details such as owner name, registration details, and contact data. By giving  inputs, clients can rapidly get the data they require about a particular car.Here we are going to use three different methods: GetCarDetailsByPlateAndEngine, using validateinput  and using the retrievecardetails function along with examples to elaborate the concept. Syntax func GetCarDetailsByPlateAndEngine(plateNumber string, engineNumber string) (*CarDetails, error) the GetCarDetailsByPlateAndEngine function takes two string parameters (plateNumber and engineNumber), and ...

Read More

Golang Program to Get Details About the Car Owner

Akhil Sharma
Akhil Sharma
Updated on 20-Jul-2023 153 Views

In this article, we point to get details about the owner of a car. The program will ask the user to input the car enlistment number, and it'll recover the related information, such as the owner's title, address, and contact data. This program can be valuable in scenarios where car ownership data has to be rapidly accessed.Here we are going to use four different methods:PromptUserInput(), ValidateInput(registrationNumber string) bool, RetrieveOwnerDetails(registrationNumber string) (string, string, string), DisplayOwnerDetails(name, address, contact string) along with examples to elaborate the concept. Syntax func PromptUserInput() string The Syntax func PromptUserInput() string defines a function named PromptUserInput that ...

Read More
Showing 31–40 of 507 articles
« Prev 1 2 3 4 5 6 51 Next »
Advertisements