GO Program to Check Whether a Number is Palindrome or Not
Simple program in go language using for...... loop to check whether an integer (entered by the user) is Palindrome or Not. if...else statement used to display final output.
Example
// Golang program to check whether a number is palindrome or not
package main
import "fmt"
func main() {
var number,remainder,temp int
var reverse int = 0
fmt.Print("Enter any positive integer : ")
fmt.Scan(&number)
temp=number
// For Loop used in format of While Loop
for{
remainder = number%10
reverse = reverse*10 + remainder
number /= 10
if(number==0){
break // Break Statement used to exit from loop
}
}
if(temp==reverse){
fmt.Printf("%d is a Palindrome",temp)
}else{
fmt.Printf("%d is not a Palindrome",temp)
}
}
Most Helpful This Week
Find out how many logical processors used by current process
Golang program for implementation LIFO Stack and FIFO Queue
Golang writing struct to JSON file
Golang program for implementation of Knuth–Morris–Pratt (KMP) Algorithm
How do you handle HTTP authentication with an HTTP client in Go?
How do you handle HTTP client caching in Go?