FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 112   



Following program shows you how to compare two strings are equal or not.
In this program we get strings from user and compare those strings using == method

package main

import "fmt"

func main() {

  var string1 string 
  var string2 string
  fmt.Println("Please enter first string:")
  fmt.Scanf("%s", &string1)
  fmt.Println("Please enter second string:")
  fmt.Scanf("%s", &string2)
  if (string1 == string2) {
  fmt.Println("Given strings are equal")
  } else {
    fmt.Println("Given strings are not equal")
  }
}

Output:

Example1:

Please enter first string:
 hello
Please enter second string:
 hello
Given strings are equal

Example2:

Please enter first string:
 hello
Please enter second string:
 HELLO
Given strings are not equal



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News