Q:

Golang program to match two same strings in different cases

0

In this program, we will check the two same strings in different cases using EqualFold() function. The EqualFold() function returns a Boolean value to the calling function.

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 check the two same strings in different cases is given below. The given program is compiled and executed successfully.

// Golang program to check same string
// in different cases

package main

import "fmt"
import "strings"

func main() {
	str1 := "INDIA"
	str2 := "india"
	str3 := "India"

	fmt.Println(strings.EqualFold(str1, str1))
	fmt.Println(strings.EqualFold(str1, str2))
	fmt.Println(strings.EqualFold(str1, str3))
}

Output:

true
true
true

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 three string variables str1str2str3. After that, we checked the equality of two strings with the different cases using EqualFold() function and print the Boolean value on the console screen.

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

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now