Go Program To Check Character is Alphabetic or Not

Go Program to check Character is alphabetic or not. In Go language, strings are different from other languages like Java, C++, Python, etc. It is a sequence of variable-width characters where each and every character is represented by one or more bytes using UTF-8 Encoding.

Go Program To Check Character is Alphabetic or Not

Source Code

package main

import (
 "fmt"
)

func checkAlphaChar(charVariable rune) {
 if (charVariable >= 'a' && charVariable <= 'z') || (charVariable >= 'A' && charVariable <= 'Z') {
  fmt.Printf("%s is an alphabet\n", string(charVariable))
 } else {
  fmt.Printf("%s is not an alphabet\n", string(charVariable))
 }

}
func main() {
 checkAlphaChar('a')
 checkAlphaChar('_')
 checkAlphaChar('s')
 checkAlphaChar('*')

}

Output