Q:

Golang program to convert the specified string into title case

belongs to collection: Golang String Programs

0

In this program, we will create two strings, and convert the specified strings into title case using strings.Title(). After that, we will print updated string on the console screen.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program/Source Code:

The source code to convert the specified string into title case is given below. The given program is compiled and executed successfully.

// Golang program to convert the specified string
// into title case

package main

import "fmt"
import "strings"

func main() {

	str1 := "hello how are you"
	str2 := "hii i am fine"

	fmt.Println(strings.Title(str1))
	fmt.Println(strings.Title(str2))
}

Output:

Hello How Are You
Hii I Am Fine

Explanation:

In the above program, we declare the package main. The main package is used to tell the Go language compiler that the package must be compiled and produced the executable file. Here, we imported the fmt package that includes the files of package fmt then we can use a function related to the fmt package.

In the main() function, we created two string variables str1str2. Then we used strings.Title() function to convert specified string into title case and print the result on the console screen.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Golang String Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
<< Golang program to replace all specified substrings...