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
Defining a type that satisfies an interface in Go Programming Language
How to delete an element from a Slice in Golang?
State and Props in React
How to create Slice of Struct in Golang?
GO Program to Generate Fibonacci Sequence Up to a Certain Number
Golang program for implementation of Huffman Coding Algorithm
Go program to find CNAME record of a domain
How to initialize the slice with values using a slice literal?
Go language Best practices to follow in 2023
How to check specific field exist in struct?