Akhil Sharma

Akhil Sharma

507 Articles Published

Articles by Akhil Sharma

Page 33 of 51

Golang program to insert a string into another string

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

In the Go programming language, strings are a built-in data type that represents sequences of characters. They are defined using double quotes (") and can contain any valid one Example characters. A string is added to or positioned within a bigger string when it is "inserted" into another string. This might be accomplished by replacing a specific substring within the bigger string or at a certain position or index within the larger string. This is frequently used in programming when a string needs to be modified or altered in a particular way, for as by adding a prefix or suffix ...

Read More

Golang Program to divide a string in 'N' equal parts

Akhil Sharma
Akhil Sharma
Updated on 20-Feb-2023 1K+ Views

In the Go programming language, strings are a built-in data type that represents sequences of characters. They are defined using double quotes (") and can contain any valid UniExample characters. When a string is divided into n equal pieces, n substrings of equal length are created. Using string splitting or string slicing techniques in programming languages, the substrings can be obtained. Let’s see the examples to understand the logic. Method 1: Using for loop and built-in append function In this method, a function called divideString is defined accepts two inputs, a string and an integer, and outputs a slice of ...

Read More

Golang Program to Lookup enum by String value

Akhil Sharma
Akhil Sharma
Updated on 20-Feb-2023 5K+ Views

In golang, the enumeration constant that corresponds to a given string is necessary to look up an enumeration (enum) by its string value. A switch statement or a string of if-else statements can be used to do this. An alternative method is to use a map, with the enumeration constants serving as the values and the string values acting as the keys. Enumeration constants can now be quickly and effectively looked up using their string form. Let’s find how to lookup enum by string value in go programming language with various example. Method 1: Using string representation In this example ...

Read More

Golang Program to convert a string into lowercase

Akhil Sharma
Akhil Sharma
Updated on 17-Feb-2023 2K+ Views

In the Go programming language, strings are a built-in data type that represents sequences of characters. They are defined using double quotes (") and can contain any valid Unicode characters. In this article we will write a go language program to convert a string to lowercase. Method 1: Using User-defined function In this method, we are going to create a user-defined function to convert a given string into lowercase using in go programming language. Algorithm Step 1 − First, we need to import the fmt package. Step 2 − Then, create a function to convert a string to lowercase. ...

Read More

Golang Program to trim a string from the left side

Akhil Sharma
Akhil Sharma
Updated on 17-Feb-2023 7K+ Views

In the Go programming language, strings are a built-in data type that represents sequences of characters. They are defined using double quotes (") and can contain any valid Unicode characters. In this article, we will write a go language program to trim a string from the left side. Method 1: Using User-Defined function In this method, we are going to create a user-defined function with for loop to iterate over the string. It will compare the character of the string to the character from the left side to be removed. If they are equal then remove that character from the ...

Read More

Golang Program to pad a string with 0's on the right side

Akhil Sharma
Akhil Sharma
Updated on 17-Feb-2023 2K+ Views

In the Go programming language, strings are a built-in data type that represents sequences of characters. They are defined using double quotes (") and can contain any valid Unicode characters. In this article we will write a go language program to pad a string with 0 on the right side of it. Method 1: Using User-defined function In this method , We are going to creating an external function. The function accepts the string to be padded along with the length as argument and returns the final string after adding zeroes to right of it. Algorithm Step 1 − ...

Read More

Golang Program to check a string starts with a specified substring

Akhil Sharma
Akhil Sharma
Updated on 17-Feb-2023 851 Views

In the Go programming language, strings are a built-in data type that represents sequences of characters. They are defined using double quotes (") and can contain any valid Unicode characters. A substring is a portion of a string that contains a sequence of characters from the original string. A substring can be obtained in Go by using the slicing syntax on a string value. In this article we will write a go language program to check whether a string starts with a specified substring or not. Here, we will use both for loops and in built functions in go programming ...

Read More

Golang Program to trim a string from the right side

Akhil Sharma
Akhil Sharma
Updated on 17-Feb-2023 3K+ Views

Strings are a built-in data type that represents sequences of characters in Golang. They are defined using double quotes (") and can contain any valid Unicode characters. In this article we will write a go language program to trim a string from the right side. We will achieve this both by using for loop and inbuilt library functions present in go language. Method 1: Using User-defined function In this method, the for loop is used to iterate over the string and then it compares the character of the string to the character from the right side to be removed. If ...

Read More

Golang Program to convert a string into Uppercase

Akhil Sharma
Akhil Sharma
Updated on 17-Feb-2023 4K+ Views

Strings are a built-in data type that represents sequences of characters in Golang. They are defined using double quotes (") and can contain any valid Unicode characters. In this article we will write a go language program to convert a string to uppercase. Here we will see the usage of both for loop and library functions to carry on the respective conversion. Method, 1: Using user-defined function In this method, we are going to create a user-defined function to convert a string into upper-case. The Steps to perform that are explained below − Algorithm Step 1 − First, we ...

Read More

Golang Program to trim a string from both sides

Akhil Sharma
Akhil Sharma
Updated on 17-Feb-2023 5K+ Views

Strings are a built-in data type that represents sequences of characters in Golang. They are defined using double quotes (") and can contain any valid Unicode characters. In this article we are going to learn about how to trim a string from both side using Go programming language. Method 1: By Using A For Loop In this method, the for loop is used to iterate over the string and then it compares the character of the string to the character of the string. If they are equal then remove that character from the string and print the remaining string. Algorithm ...

Read More
Showing 321–330 of 507 articles
« Prev 1 31 32 33 34 35 51 Next »
Advertisements