Go Saved Program: placid-terrain

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.


//This GO program will take a string and tell whether it is palindrome or not
package main

import (
 "fmt"
 "strings"
)

func main() {

 var ip string
 fmt.Println("Enter string:")
 fmt.Scanf("%s\n", &ip)
 ip = strings.ToLower(ip)
 fmt.Println(isP(ip))
}
//Function to test if th e string entered is a Palindrome

func isP(s string) string {
 mid := len(s) / 2
 last := len(s) - 1
 for i := 0; i < mid; i++ {
  if s[i] != s[last-i] {
   return "NO. the string is not a valid Palimdrome."
  }
 }
 return "YES! the string a Palindrome"
}
Execute

Output

Press the execute button or CTRL + enter to run code.

Inputs